mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
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>
This commit is contained in:
parent
2fbad29917
commit
9d8a6b2a02
@ -129,13 +129,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user