mirror of
https://github.com/torvalds/linux.git
synced 2025-11-30 23:16:01 +07:00
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>
This commit is contained in:
committed by
Andrew Morton
parent
3d5f4f15b7
commit
3e3f55f8b7
@@ -653,9 +653,9 @@ int btree_merge(struct btree_head *target, struct btree_head *victim,
|
||||
* walks to remove a single object from the victim.
|
||||
*/
|
||||
for (;;) {
|
||||
if (!btree_last(victim, geo, key))
|
||||
val = btree_last(victim, geo, key);
|
||||
if (!val)
|
||||
break;
|
||||
val = btree_lookup(victim, geo, key);
|
||||
err = btree_insert(target, geo, key, val, gfp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user