diff options
author | Volker Lendecke <vl@samba.org> | 2019-08-04 12:18:19 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-08-06 21:49:27 +0000 |
commit | 897bffa8166f643eb9063a848bb0c02455663317 (patch) | |
tree | 33ed9071b15e647d70ce11916c4b8cae09c0e665 /lib/tdb | |
parent | 5a388453e0cb038fa3ed5fb46f972470f7793566 (diff) | |
download | samba-897bffa8166f643eb9063a848bb0c02455663317.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>
Diffstat (limited to 'lib/tdb')
-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; } |