summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2011-03-11 10:25:11 +0900
committerAkira TAGOH <akira@tagoh.org>2011-03-11 10:25:11 +0900
commitb500e9b0268594d7ba603d0017a594725caf599f (patch)
treebbc05223de4fc041e47c4226967166b6c75838d6
parentd9f24cf8260f6e3b35c48404f38c3d06441722c4 (diff)
trivial optimization to reduce the search cost on the memory management
-rw-r--r--hieroglyph/hgallocator.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hieroglyph/hgallocator.c b/hieroglyph/hgallocator.c
index 0fa174d..27c0c3d 100644
--- a/hieroglyph/hgallocator.c
+++ b/hieroglyph/hgallocator.c
@@ -343,7 +343,12 @@ _hg_allocator_bitmap_free(hg_allocator_bitmap_t *bitmap,
for (i = idx; i < (idx + aligned_size); i++)
_hg_allocator_bitmap_clear(bitmap, page, i);
- bitmap->last_index[page] = i - 1;
+ if (bitmap->last_index[page] > (i - 1)) {
+ /* only update the last index when it points out
+ * bigger index to reduce the search cost.
+ */
+ bitmap->last_index[page] = i - 1;
+ }
G_UNLOCK (bitmap);