From: Volker Lendecke Date: Sun, 4 Aug 2019 16:26:05 +0000 (+0200) Subject: tdb: Inline the common part of tdb_oob X-Git-Tag: tdb-1.4.2~321 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f5735e2c666a5a494131c1d25f7ba5c7fbeae923;p=thirdparty%2Fsamba.git tdb: Inline the common part of tdb_oob When you set in tdbtorture.c to make it more similar to locking.tdb use, bin/tdbtorture -m -n 1 -l 100000 -s becomes twice as fast. This is a pretty extreme case, but all other tests that I did improve significantly as well. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c index 28e808143a2..0de0dabd827 100644 --- a/lib/tdb/common/io.c +++ b/lib/tdb/common/io.c @@ -667,15 +667,9 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size) return -1; } -int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe) +int _tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe) { - int ret; - - if (likely((off + len >= off) && (off + len <= tdb->map_size))) { - return 0; - } - - ret = tdb->methods->tdb_oob(tdb, off, len, probe); + int ret = tdb->methods->tdb_oob(tdb, off, len, probe); return ret; } diff --git a/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h index 2bed8200f94..29790434211 100644 --- a/lib/tdb/common/tdb_private.h +++ b/lib/tdb/common/tdb_private.h @@ -304,7 +304,19 @@ void *tdb_convert(void *buf, uint32_t size); int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec); tdb_off_t tdb_allocate(struct tdb_context *tdb, int hash, tdb_len_t length, struct tdb_record *rec); -int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe); + +int _tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe); + +static inline int tdb_oob( + struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe) +{ + if (likely((off + len >= off) && (off + len <= tdb->map_size))) { + return 0; + } + return _tdb_oob(tdb, off, len, probe); +} + + int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d); int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d); int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off);