[PATCH] befs (3/5): binary search microoptimisation

From: Sergey S. Kostyliov
Date: Thu May 13 2004 - 13:42:22 EST


Move value initialisation out of the loop body.

===== fs/befs/btree.c 1.6 vs edited =====
--- 1.6/fs/befs/btree.c Sun Jul 13 19:55:50 2003
+++ edited/fs/befs/btree.c Thu May 13 19:45:39 2004
@@ -372,12 +372,12 @@
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 @@
}
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;
}

--
Best regards,
Sergey S. Kostyliov <rathamahata@xxxxxxx>
Public PGP key: http://sysadminday.org.ru/rathamahata.asc

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/