History

find: micro-optimize for_each_{set,clear}_bit()

The macros iterate thru all set/clear bits in a bitmap. They search a first bit using find_first_bit(), and the rest bits using find_next_bit(). Since find_next_bit() is called shortly after find_first_bit(), we can save few lines of I-cache by not using find_first_bit().

Yury Norov committed 5 years ago

Commit 7516be91 parent bc9d6631 file · +2 −2Browse files

Showing the changes to include (1 of 1 file). Show all

Unified · Split

include/linux/find.h+2−2
@@ -280,7 +280,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned · 279 unmodified lines
280280 #endif
281281
282282 #define for_each_set_bit(bit, addr, size) \
283− for ((bit) = find_first_bit((addr), (size)); \
283+ for ((bit) = find_next_bit((addr), (size), 0); \
284284 (bit) < (size); \
285285 (bit) = find_next_bit((addr), (size), (bit) + 1))
286286
@@ -291,7 +291,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned · 4 unmodified lines
291291 (bit) = find_next_bit((addr), (size), (bit) + 1))
292292
293293 #define for_each_clear_bit(bit, addr, size) \
294− for ((bit) = find_first_zero_bit((addr), (size)); \
294+ for ((bit) = find_next_zero_bit((addr), (size), 0); \
295295 (bit) < (size); \
296296 (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
297297

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t