]> git.hungrycats.org Git - linux/commitdiff
[PATCH] bitmap_snprintf() optimization
authorAndrew Morton <akpm@osdl.org>
Sun, 8 Feb 2004 01:42:08 +0000 (17:42 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Sun, 8 Feb 2004 01:42:08 +0000 (17:42 -0800)
From: Joe Korty <joe.korty@ccur.com>

Now that bitmap_parse is part of bitmap.[ch], it is allowed to manipulate
bits directly as the other bitmap routines do.

lib/bitmap.c

index fb09dffaa557ba23deea92b3dca8f9dd96fee9f5..5e93a93c0136e15d22f49bf6e2af1dea37e46f48 100644 (file)
@@ -220,7 +220,7 @@ EXPORT_SYMBOL(bitmap_snprintf);
 int bitmap_parse(const char __user *ubuf, unsigned int ubuflen,
         unsigned long *maskp, int nmaskbits)
 {
-       int i, c, old_c, totaldigits, ndigits, nchunks, nbits;
+       int c, old_c, totaldigits, ndigits, nchunks, nbits;
        u32 chunk;
 
        bitmap_clear(maskp, nmaskbits);
@@ -270,9 +270,7 @@ int bitmap_parse(const char __user *ubuf, unsigned int ubuflen,
                        continue;
 
                bitmap_shift_right(maskp, maskp, CHUNKSZ, nmaskbits);
-               for (i = 0; i < CHUNKSZ; i++)
-                       if (chunk & (1 << i))
-                               set_bit(i, maskp);
+               *maskp |= chunk;
                nchunks++;
                nbits += (nchunks == 1) ? nbits_to_hold_value(chunk) : CHUNKSZ;
                if (nbits > nmaskbits)