From 9ee746aa83bd7f204e571655afe1a0cadf7ef451 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 10 May 2013 09:57:25 +1000 Subject: [PATCH] lib-bitmapc-speed-up-bitmap_find_free_region-fix reduce scope of locals, remove barely comprehensible comment Cc: Chanho Min Cc: Jiri Kosina Cc: Joe Perches Cc: Nadia Yvette Chambers Cc: anish singh Signed-off-by: Andrew Morton --- lib/bitmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/bitmap.c b/lib/bitmap.c index 95e8efc18f68..ea190b7047c3 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -1114,13 +1114,15 @@ done: */ int bitmap_find_free_region(unsigned long *bitmap, int bits, int order) { - int pos, end, nbit, i; /* scans bitmap by regions of size order */ int nlongs = BITS_TO_LONGS(bits); + int i; for (i = 0; i < nlongs; i++) if (bitmap[i] != ~0UL) { - pos = i * BITS_PER_LONG; - nbit = min(bits, pos + BITS_PER_LONG); + int pos = i * BITS_PER_LONG; + int nbit = min(bits, pos + BITS_PER_LONG); + int end; + for (; (end = pos + (1 << order)) <= nbit; pos = end) { if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) -- 2.39.5