mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Sergey S. Kostyliov" <rathamahata@php4.ru>
To: linux-kernel@vger.kernel.org
Cc: Will Dyson <will_dyson@pobox.com>
Subject: [PATCH] befs (3/5): binary search microoptimisation
Date: Thu, 13 May 2004 22:21:18 +0400	[thread overview]
Message-ID: <E1BOL04-0003ou-02@mail.ehouse.ru> (raw)

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@php4.ru>
                   Public PGP key: http://sysadminday.org.ru/rathamahata.asc


                 reply	other threads:[~2004-05-13 18:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1BOL04-0003ou-02@mail.ehouse.ru \
    --to=rathamahata@php4.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will_dyson@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®