diff mbox series

[3/3] btrfs: avoid redundant slot assignment in btrfs_search_forward()

Message ID 20250309075820.30999-4-sunk67188@gmail.com (mailing list archive)
State New
Headers show
Series btrfs: random code cleanup | expand

Commit Message

Sun YangKai March 9, 2025, 7:58 a.m. UTC
This patch moves `path->slots[level] = slot` before the condition check
to prevent duplicate assignment. Previously, the slot was set both inside
and after the `slot >= nritems` block with no change in its value, which
is unnecessary.

Signed-off-by: Sun YangKai <sunk67188@gmail.com>
---
 fs/btrfs/ctree.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 1dc59dc3b708..7e9562a59282 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -4668,8 +4668,8 @@  int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
 		 * we didn't find a candidate key in this node, walk forward
 		 * and find another one
 		 */
+		path->slots[level] = slot;
 		if (slot >= nritems) {
-			path->slots[level] = slot;
 			sret = btrfs_find_next_key(root, path, min_key, level,
 						  min_trans);
 			if (sret == 0) {
@@ -4679,7 +4679,6 @@  int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
 				goto out;
 			}
 		}
-		path->slots[level] = slot;
 		if (level == path->lowest_level) {
 			ret = 0;
 			/* save our key for returning back */