Commit fab4f8c6 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Make __bch2_bkey_cmp_packed() smaller

We can probably get rid of the version that dispatches based on type
checking too.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 6baf2730
...@@ -1061,26 +1061,20 @@ int __bch2_bkey_cmp_packed(const struct bkey_packed *l, ...@@ -1061,26 +1061,20 @@ int __bch2_bkey_cmp_packed(const struct bkey_packed *l,
const struct bkey_packed *r, const struct bkey_packed *r,
const struct btree *b) const struct btree *b)
{ {
int packed = bkey_lr_packed(l, r); struct bkey unpacked;
if (likely(packed == BKEY_PACKED_BOTH)) if (likely(bkey_packed(l) && bkey_packed(r)))
return __bch2_bkey_cmp_packed_format_checked(l, r, b); return __bch2_bkey_cmp_packed_format_checked(l, r, b);
switch (packed) { if (bkey_packed(l)) {
case BKEY_PACKED_NONE: __bkey_unpack_key_format_checked(b, &unpacked, l);
return bkey_cmp(((struct bkey *) l)->p, l = (void*) &unpacked;
((struct bkey *) r)->p); } else if (bkey_packed(r)) {
case BKEY_PACKED_LEFT: __bkey_unpack_key_format_checked(b, &unpacked, r);
return __bch2_bkey_cmp_left_packed_format_checked(b, r = (void*) &unpacked;
(struct bkey_packed *) l,
&((struct bkey *) r)->p);
case BKEY_PACKED_RIGHT:
return -__bch2_bkey_cmp_left_packed_format_checked(b,
(struct bkey_packed *) r,
&((struct bkey *) l)->p);
default:
unreachable();
} }
return bkey_cmp(((struct bkey *) l)->p, ((struct bkey *) r)->p);
} }
__pure __flatten __pure __flatten
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment