From: Andrew Morton <akpm@linux-foundation.org>
To: Leno Hou <lenohou@gmail.com>
Cc: linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com,
hch@infradead.org
Subject: Re: [PATCH v2] lib/btree.c: optimise the code by previously getpos function
Date: Fri, 12 May 2017 13:58:58 -0700 [thread overview]
Message-ID: <20170512135858.701ce87f51c7fa255db7d642@linux-foundation.org> (raw)
In-Reply-To: <1494495741-30760-1-git-send-email-lenohou@gmail.com>
On Thu, 11 May 2017 17:42:21 +0800 Leno Hou <lenohou@gmail.com> wrote:
> This patch optimized the code by previously getpos function call.
> Therefore, It's takes the convenience to understand logic of code.
I would rewrite this changelog to read
: Rework the getpos() helper function and use it to remove various
: open-coded implemetnations of its funtionality.
> ...
>
> @@ -466,7 +458,7 @@ static int btree_insert_level(struct btree_head *head, struct btree_geo *geo,
> /* two identical keys are not allowed */
> BUG_ON(pos < fill && keycmp(geo, node, pos, key) == 0);
>
> - if (fill == geo->no_pairs) {
> + if (fill < 0) {
> /* need to split node */
> unsigned long *new;
The code here is a bit awkward.
: retry:
: node = find_level(head, geo, key, level);
: pos = getpos(geo, node, key);
: fill = getfill(geo, node, pos);
: /* two identical keys are not allowed */
: BUG_ON(pos < fill && keycmp(geo, node, pos, key) == 0);
:
: if (fill < 0) {
If getpos() returns -ENOENT then we're passing -ENOENT into getfill().
That might happen to work OK (or it might go BUG) but it's ugly and
unobvious.
There's a similar issue in rebalance() and in btree_remove_level():
failed to update existing getpos() callers for the new getpos() return
value semantics.
prev parent reply other threads:[~2017-05-12 20:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 9:42 Leno Hou
2017-05-11 11:00 ` Andy Shevchenko
2017-05-12 20:58 ` Andrew Morton [this message]
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=20170512135858.701ce87f51c7fa255db7d642@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andy.shevchenko@gmail.com \
--cc=hch@infradead.org \
--cc=lenohou@gmail.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®