@@ -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)
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@gmail.com> --- fs/btrfs/inode.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)