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 <[email protected]> --- fs/btrfs/ctree.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a3a75f1de..318379531 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -460,15 +460,17 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm) while (*new) { cur = rb_entry(*new, struct tree_mod_elem, node); parent = *new; - if (cur->logical < tm->logical) - new = &((*new)->rb_left); - else if (cur->logical > tm->logical) - new = &((*new)->rb_right); - else if (cur->seq < tm->seq) - new = &((*new)->rb_left); - else if (cur->seq > tm->seq) - new = &((*new)->rb_right); - else + if (cur->logical != tm->logical) { + if (cur->logical < tm->logical) + new = &((*new)->rb_left); + else + new = &((*new)->rb_right); + } else if (cur->seq != tm->seq) { + if (cur->seq < tm->seq) + new = &((*new)->rb_left); + else + new = &((*new)->rb_right); + } else return -EEXIST; } -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
