Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btree: simplify merge logic by using btree_last() return value

Previously btree_merge() called btree_last() only to test existence, then
performed an extra btree_lookup() to fetch the value. This patch changes
it to directly use the value returned by btree_last(), avoiding redundant
lookups and simplifying the merge loop.

Link: https://lkml.kernel.org/r/20250826161741.686704-1-409411716@gms.tku.edu.tw
Signed-off-by: Guan-Chun Wu <409411716@gms.tku.edu.tw>
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Guan-Chun Wu and committed by
Andrew Morton
3e3f55f8 3d5f4f15

+2 -2
+2 -2
lib/btree.c
··· 653 653 * walks to remove a single object from the victim. 654 654 */ 655 655 for (;;) { 656 - if (!btree_last(victim, geo, key)) 656 + val = btree_last(victim, geo, key); 657 + if (!val) 657 658 break; 658 - val = btree_lookup(victim, geo, key); 659 659 err = btree_insert(target, geo, key, val, gfp); 660 660 if (err) 661 661 return err;