@@ -120,25 +120,29 @@ static void ref_root_free(struct ref_root *ref_tree)
*/
static int ref_node_cmp(struct ref_node *a, struct ref_node *b)
{
- if (a->root_id < b->root_id)
- return -1;
- else if (a->root_id > b->root_id)
+ if (a->root_id != b->root_id) {
+ if (a->root_id < b->root_id)
+ return -1;
return 1;
+ }
- if (a->object_id < b->object_id)
- return -1;
- else if (a->object_id > b->object_id)
+ if (a->object_id != b->object_id) {
+ if (a->object_id < b->object_id)
+ return -1;
return 1;
+ }
- if (a->offset < b->offset)
- return -1;
- else if (a->offset > b->offset)
+ if (a->offset != b->offset) {
+ if (a->offset < b->offset)
+ return -1;
return 1;
+ }
- if (a->parent < b->parent)
- return -1;
- else if (a->parent > b->parent)
+ if (a->parent != b->parent) {
+ if (a->parent < b->parent)
+ return -1;
return 1;
+ }
return 0;
}
In worst case code do 8 comparison, just add some new checks to switch check branch faster now in worst case code do 5 comparison Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com> --- fs/btrfs/backref.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)