DescriptionSpeed up IdAllocator.
I noticed while debugging that FindFirstFree() was iterating
through all existing IDs, so it's O(n^2). This CL makes most
operations constant time by adding an explicit freelist (but
we need to fall back to a linear search in the worst case).
This will increase memory usage slightly, but only by as much
as the maximum number of IDs that were in use at any one time.
We won't get "garbage IDs" building up over time.
MarkAsUsed and FreeID both do an erase/insert pair. The erase
could be optimised out (as we've already done the lookup by
this point) but I figured it was clearer and simpler this way.
TEST=Existing
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=87026
Patch Set 1 #Patch Set 2 : '' #Patch Set 3 : Clarified description. #
Total comments: 1
Messages
Total messages: 10 (0 generated)
|