From: Timofey Titovets <nefelim4ag@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Timofey Titovets <nefelim4ag@gmail.com>
Subject: [PATCH 1/7] Btrfs: __compare_inode_defrag decrease max compare count
Date: Wed, 7 Jun 2017 03:58:38 +0300 [thread overview]
Message-ID: <20170607005844.2078-2-nefelim4ag@gmail.com> (raw)
In-Reply-To: <20170607005844.2078-1-nefelim4ag@gmail.com>
In worst case code do 4 comparison,
just add some new checks to switch check branch faster
now in worst case code do 3 comparison
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
---
fs/btrfs/file.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index da1096eb1..39efda26c 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -71,16 +71,17 @@ struct inode_defrag {
static int __compare_inode_defrag(struct inode_defrag *defrag1,
struct inode_defrag *defrag2)
{
- if (defrag1->root > defrag2->root)
- return 1;
- else if (defrag1->root < defrag2->root)
+ if (defrag1->root != defrag2->root) {
+ if (defrag1->root > defrag2->root)
+ return 1;
return -1;
- else if (defrag1->ino > defrag2->ino)
- return 1;
- else if (defrag1->ino < defrag2->ino)
+ }
+ if (defrag1->ino != defrag2->ino) {
+ if (defrag1->ino > defrag2->ino)
+ return 1;
return -1;
- else
- return 0;
+ }
+ return 0;
}
/* pop a record for an inode into the defrag tree. The lock
--
2.13.0
next prev parent reply other threads:[~2017-06-07 1:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 0:58 [PATCH 0/7] Btrfs: if else cleanups Timofey Titovets
2017-06-07 0:58 ` Timofey Titovets [this message]
2017-06-07 0:58 ` [PATCH 2/7] Btrfs: backref_comp decrease max compare count Timofey Titovets
2017-06-07 0:58 ` [PATCH 3/7] Btrfs: ref_node_cmp " Timofey Titovets
2017-06-07 0:58 ` [PATCH 4/7] Btrfs: ref_tree_add remove useless compare Timofey Titovets
2017-06-07 0:58 ` [PATCH 5/7] Btrfs: add_all_parents skip compare Timofey Titovets
2017-06-07 0:58 ` [PATCH 6/7] Btrfs: __tree_mod_log_insert decrease max compare count Timofey Titovets
2017-06-07 9:45 ` Filipe Manana
2017-06-07 11:01 ` Timofey Titovets
2017-06-13 14:24 ` David Sterba
2017-06-07 0:58 ` [PATCH 7/7] Btrfs: end_workqueue_bio use switch case instead of else if Timofey Titovets
2017-06-07 22:48 ` kbuild test robot
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=20170607005844.2078-2-nefelim4ag@gmail.com \
--to=nefelim4ag@gmail.com \
--cc=linux-btrfs@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).