Commit d22b1c8d authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] befs: binary search microoptimisation

From: "Sergey S. Kostyliov" <rathamahata@php4.ru>

Move value initialisation out of the loop body.
parent 4286d673
...@@ -372,12 +372,12 @@ befs_find_key(struct super_block *sb, befs_btree_node * node, ...@@ -372,12 +372,12 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
thiskey = befs_bt_get_key(sb, node, mid, &keylen); thiskey = befs_bt_get_key(sb, node, mid, &keylen);
eq = befs_compare_strings(thiskey, keylen, findkey, eq = befs_compare_strings(thiskey, keylen, findkey,
findkey_len); findkey_len);
*value = fs64_to_cpu(sb, valarray[mid]);
if (eq == 0) { if (eq == 0) {
befs_debug(sb, "<--- befs_find_key() found %s at %d", befs_debug(sb, "<--- befs_find_key() found %s at %d",
thiskey, mid); thiskey, mid);
*value = fs64_to_cpu(sb, valarray[mid]);
return BEFS_BT_MATCH; return BEFS_BT_MATCH;
} }
if (eq > 0) if (eq > 0)
...@@ -387,6 +387,8 @@ befs_find_key(struct super_block *sb, befs_btree_node * node, ...@@ -387,6 +387,8 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
} }
if (eq < 0) if (eq < 0)
*value = fs64_to_cpu(sb, valarray[mid + 1]); *value = fs64_to_cpu(sb, valarray[mid + 1]);
else
*value = fs64_to_cpu(sb, valarray[mid]);
befs_debug(sb, "<--- befs_find_key() found %s at %d", thiskey, mid); befs_debug(sb, "<--- befs_find_key() found %s at %d", thiskey, mid);
return BEFS_BT_PARMATCH; return BEFS_BT_PARMATCH;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment