]> git.hungrycats.org Git - linux/commitdiff
[PATCH] befs: binary search microoptimisation
authorAndrew Morton <akpm@osdl.org>
Fri, 14 May 2004 12:51:06 +0000 (05:51 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 14 May 2004 12:51:06 +0000 (05:51 -0700)
From: "Sergey S. Kostyliov" <rathamahata@php4.ru>

Move value initialisation out of the loop body.

fs/befs/btree.c

index e1a0256f586c16e71323acacc347d944125acaf9..76e2197994095ca57c6f3c712e7b15e9b47e700e 100644 (file)
@@ -372,12 +372,12 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
                thiskey = befs_bt_get_key(sb, node, mid, &keylen);
                eq = befs_compare_strings(thiskey, keylen, findkey,
                                          findkey_len);
-               *value = fs64_to_cpu(sb, valarray[mid]);
 
                if (eq == 0) {
                        befs_debug(sb, "<--- befs_find_key() found %s at %d",
                                   thiskey, mid);
 
+                       *value = fs64_to_cpu(sb, valarray[mid]);
                        return BEFS_BT_MATCH;
                }
                if (eq > 0)
@@ -387,6 +387,8 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
        }
        if (eq < 0)
                *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);
        return BEFS_BT_PARMATCH;
 }