]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: make bset_search_tree() be more understandable
authorColy Li <colyli@suse.de>
Fri, 28 Jun 2019 11:59:41 +0000 (19:59 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Jun 2019 13:39:15 +0000 (07:39 -0600)
commit536aa8dff528154cf9e0a83f15c5201da325e0ef
treeee17c3e2ffce34f6e38b8036fab760e8c82f02d4
parent720a994bdd8ba5b11b42a08bd3538136a11b4395
bcache: make bset_search_tree() be more understandable

The purpose of following code in bset_search_tree() is to avoid a branch
instruction,
 994         if (likely(f->exponent != 127))
 995                 n = j * 2 + (((unsigned int)
 996                               (f->mantissa -
 997                                bfloat_mantissa(search, f))) >> 31);
 998         else
 999                 n = (bkey_cmp(tree_to_bkey(t, j), search) > 0)
1000                         ? j * 2
1001                         : j * 2 + 1;

This piece of code is not very clear to understand, even when I tried to
add code comment for it, I made mistake. This patch removes the implict
bit operation and uses explicit branch to calculate next location in
binary tree search.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/bset.c