From ed1646ca7412151dbdd81f4e4d05437cc99e9c8c Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 22 Jan 2019 13:46:14 -0500 Subject: bcachefs: Improve c version of __bkey_cmp_bits Signed-off-by: Kent Overstreet --- fs/bcachefs/bkey.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'fs/bcachefs/bkey.c') diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index d35cdde299c4..8a3295ff9631 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -1014,11 +1014,8 @@ static inline int __bkey_cmp_bits(const u64 *l, const u64 *r, nr_key_bits -= 64; } - if (l_v != r_v) - return l_v < r_v ? -1 : 1; - - if (!nr_key_bits) - return 0; + if (!nr_key_bits || l_v != r_v) + break; l = next_word(l); r = next_word(r); @@ -1026,6 +1023,8 @@ static inline int __bkey_cmp_bits(const u64 *l, const u64 *r, l_v = *l; r_v = *r; } + + return (l_v > r_v) - (l_v < r_v); } #endif -- cgit v1.2.3