diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-11-07 21:03:09 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:08:31 +0200 |
commit | fab4f8c6538810e31d7d853333143621091f5dd0 (patch) | |
tree | 18b2d75b5f527a9653af5ed5a29b143300dfe44a /fs/bcachefs/bkey.c | |
parent | bcachefs: Inline fast path of bch2_increment_clock() (diff) | |
download | linux-fab4f8c6538810e31d7d853333143621091f5dd0.tar.xz linux-fab4f8c6538810e31d7d853333143621091f5dd0.zip |
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: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bkey.c')
-rw-r--r-- | fs/bcachefs/bkey.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index dd551cc3a162..32e4917dc004 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -1061,26 +1061,20 @@ int __bch2_bkey_cmp_packed(const struct bkey_packed *l, const struct bkey_packed *r, 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); - switch (packed) { - case BKEY_PACKED_NONE: - return bkey_cmp(((struct bkey *) l)->p, - ((struct bkey *) r)->p); - case BKEY_PACKED_LEFT: - return __bch2_bkey_cmp_left_packed_format_checked(b, - (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(); + if (bkey_packed(l)) { + __bkey_unpack_key_format_checked(b, &unpacked, l); + l = (void*) &unpacked; + } else if (bkey_packed(r)) { + __bkey_unpack_key_format_checked(b, &unpacked, r); + r = (void*) &unpacked; } + + return bkey_cmp(((struct bkey *) l)->p, ((struct bkey *) r)->p); } __pure __flatten |