linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: minskey <chaohong_guo@linux.intel.com>
To: linux-ext4@vger.kernel.org
Subject: binary search in ext4_ext_binsearch_idx()
Date: Thu, 08 Apr 2010 11:26:16 +0800	[thread overview]
Message-ID: <1270697176.21760.27.camel@minskey-desktop> (raw)



in ext4_ext_binsearch_idx() routine, there is the following code:

 while (l <= r) {
                m = l + (r - l) / 2;
                if (block < le32_to_cpu(m->ei_block))
                        r = m - 1;
                else
                        l = m + 1;
 }

 path->p_idx = l - 1;

The code always runs logN iterations to get the expected extent,
if 3-way comparison is used, we can save some iterations when 
(block == le32_to_cpu(m->ei_block)) at the first iteration.

some other routines, such as ext4_ext_binsearch() etc, use the
same algorithm (2-way comparison), Is there any special goal ? 



thanks,
-minskey





                 reply	other threads:[~2010-04-08  3:38 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=1270697176.21760.27.camel@minskey-desktop \
    --to=chaohong_guo@linux.intel.com \
    --cc=linux-ext4@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).