]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: remove duplicate calculation of eb offset in btrfs_bin_search()
authorDavid Sterba <dsterba@suse.com>
Tue, 6 Jan 2026 16:20:24 +0000 (17:20 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:56:07 +0000 (18:56 +0200)
In the main search loop the variable 'oil' (offset in folio) is set
twice, one duplicated when the key fits completely to the contiguous
range. We can remove it and while it's just a simple calculation, the
binary search loop is executed many times so micro optimizations add up.

The code size is reduced by 64 bytes on release config, the loop is
reorganized a bit and a few instructions shorter.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c

index 5c68c541de516f4edb81fe729801c781824d9b0c..eae69e205b28824f1f51c02ac38c1c51bfb8bb9c 100644 (file)
@@ -781,7 +781,6 @@ int btrfs_bin_search(const struct extent_buffer *eb, int first_slot,
                        const unsigned long idx = get_eb_folio_index(eb, offset);
                        char *kaddr = folio_address(eb->folios[idx]);
 
-                       oil = get_eb_offset_in_folio(eb, offset);
                        tmp = (struct btrfs_disk_key *)(kaddr + oil);
                } else {
                        read_extent_buffer(eb, &unaligned, offset, key_size);