Trivial performance optimisation
authorIustin Pop <iustin@google.com>
Fri, 30 Dec 2011 15:49:00 +0000 (16:49 +0100)
committerIustin Pop <iustin@google.com>
Fri, 13 Jan 2012 13:17:06 +0000 (14:17 +0100)
This is not in the hot-path, but still, no sense in doing O(n) instead
of O(1).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

htools/Ganeti/HTools/Cluster.hs

index d3b1bc7..67dff0c 100644 (file)
@@ -1158,7 +1158,7 @@ iterateAlloc :: AllocMethod
 iterateAlloc nl il limit newinst allocnodes ixes cstats =
   let depth = length ixes
       newname = printf "new-%d" depth::String
-      newidx = length (Container.elems il) + depth
+      newidx = Container.size il + depth
       newi2 = Instance.setIdx (Instance.setName newinst newname) newidx
       newlimit = fmap (flip (-) 1) limit
   in case tryAlloc nl il newi2 allocnodes of