In worst case code do 6 comparison,
just add some new checks to switch check branch faster
now in worst case code do 4 comparison
Signed-off-by: Timofey Titovets <nefelim4ag@xxxxxxxxx>
---
fs/btrfs/inode.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 17cbe9306..fa024642a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2249,20 +2249,23 @@ struct new_sa_defrag_extent {
static int backref_comp(struct sa_defrag_extent_backref *b1,
struct sa_defrag_extent_backref *b2)
{
- if (b1->root_id < b2->root_id)
- return -1;
- else if (b1->root_id > b2->root_id)
+ if (b1->root_id != b2->root_id) {
+ if (b1->root_id < b2->root_id)
+ return -1;
return 1;
+ }
- if (b1->inum < b2->inum)
- return -1;
- else if (b1->inum > b2->inum)
+ if (b1->inum != b2->inum) {
+ if (b1->inum < b2->inum)
+ return -1;
return 1;
+ }
- if (b1->file_pos < b2->file_pos)
- return -1;
- else if (b1->file_pos > b2->file_pos)
+ if (b1->file_pos != b2->file_pos) {
+ if (b1->file_pos < b2->file_pos)
+ return -1;
return 1;
+ }
/*
* [------------------------------] ===> (a range of space)
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html