diff options
| author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-02-13 14:36:05 -0800 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-11 10:59:35 +0200 |
| commit | 4e8ee1ec9f82e439d45e655b47b49b2866cc1cc4 (patch) | |
| tree | 36aece86571e28df2df8d9836e1acbaa02fc4e36 /lib | |
| parent | 47894066de6270d11af8da2a1d7cd9a19d8f9180 (diff) | |
lib: bitmap: eliminate branch in __bitmap_shift_right
We can shift the bits from lower and upper into place before assembling
dst[k]; moving the shift of upper into the branch where we already know
that rem is non-zero allows us to remove a conditional.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bitmap.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 92395bc21..204f09607 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -127,13 +127,13 @@ void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, upper = src[off + k + 1]; if (off + k + 1 == lim - 1 && left) upper &= mask; + upper <<= (BITS_PER_LONG - rem); } lower = src[off + k]; if (left && off + k == lim - 1) lower &= mask; - dst[k] = lower >> rem; - if (rem) - dst[k] |= upper << (BITS_PER_LONG - rem); + lower >>= rem; + dst[k] = lower | upper; if (left && k == lim - 1) dst[k] &= mask; } |
