Index: runtime/vm/freelist.cc |
diff --git a/runtime/vm/freelist.cc b/runtime/vm/freelist.cc |
index 391dd22bcde0decd7b8f4f013a7e948e66aed057..ffc88aeaf5a4d441f8f51cf996b55c5cb6a89cd4 100644 |
--- a/runtime/vm/freelist.cc |
+++ b/runtime/vm/freelist.cc |
@@ -54,17 +54,17 @@ uword FreeList::TryAllocate(intptr_t size) { |
return reinterpret_cast<uword>(DequeueElement(index)); |
} |
- if (index < kNumLists) { |
- index++; |
- while (index < kNumLists) { |
- if (free_map_.Test(index)) { |
- // Dequeue an element from the list, split and enqueue the remainder in |
- // the appropriate list. |
- FreeListElement* element = DequeueElement(index); |
- SplitElementAfterAndEnqueue(element, size); |
- return reinterpret_cast<uword>(element); |
- } |
- index++; |
+ if ((index + 1) < kNumLists) { |
+ intptr_t next_index = free_map_.Next(index + 1); |
+ if (next_index == kNumLists) { |
+ next_index = -1; |
+ } |
siva
2012/07/24 01:07:43
per offline discussion this check could go away if
|
+ if (next_index != -1) { |
+ // Dequeue an element from the list, split and enqueue the remainder in |
+ // the appropriate list. |
+ FreeListElement* element = DequeueElement(next_index); |
+ SplitElementAfterAndEnqueue(element, size); |
+ return reinterpret_cast<uword>(element); |
} |
} |