diff options
author | Volker Lendecke <vl@samba.org> | 2019-08-04 12:18:19 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-08-21 08:40:16 +0000 |
commit | 3325a4d4146d5793b1ae6a7b7a502c52a489ac59 (patch) | |
tree | c4fc56c2b90011e2ec8b16235f0e689cfd492772 /lib | |
parent | 6312223d6e609d629dfc7914d62bf80ced584c6b (diff) | |
download | samba-3325a4d4146d5793b1ae6a7b7a502c52a489ac59.tar.gz |
tdb: Speed up tdb_oob()
This is common between both implementations of tdb_oob(). It's
faster if we don't have to dereference function pointers.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 897bffa8166f643eb9063a848bb0c02455663317)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tdb/common/io.c | 13 | ||||
-rw-r--r-- | lib/tdb/common/transaction.c | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c index f3ea7bf9856..28e808143a2 100644 --- a/lib/tdb/common/io.c +++ b/lib/tdb/common/io.c @@ -150,6 +150,11 @@ static int tdb_notrans_oob( return -1; } + /* + * This duplicates functionality from tdb_oob(). Don't remove: + * we still have direct callers of tdb->methods->tdb_oob() + * inside transaction.c. + */ if (off + len <= tdb->map_size) return 0; if (tdb->flags & TDB_INTERNAL) { @@ -664,7 +669,13 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size) int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe) { - int ret = tdb->methods->tdb_oob(tdb, off, len, probe); + int ret; + + if (likely((off + len >= off) && (off + len <= tdb->map_size))) { + return 0; + } + + ret = tdb->methods->tdb_oob(tdb, off, len, probe); return ret; } diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c index b22624820d7..4f8d1f8cdcc 100644 --- a/lib/tdb/common/transaction.c +++ b/lib/tdb/common/transaction.c @@ -378,6 +378,11 @@ static void transaction_next_hash_chain(struct tdb_context *tdb, uint32_t *chain static int transaction_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe) { + /* + * This duplicates functionality from tdb_oob(). Don't remove: + * we still have direct callers of tdb->methods->tdb_oob() + * inside transaction.c. + */ if (off + len >= off && off + len <= tdb->map_size) { return 0; } |