summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-08-04 18:26:05 +0200
committerKarolin Seeger <kseeger@samba.org>2019-08-21 08:40:16 +0000
commitafd6b77bb849bdcfa30513626c61a7aade7d88e2 (patch)
treeaf3577c44a129faf9176469e64281ddf087d8d9c /lib
parent3325a4d4146d5793b1ae6a7b7a502c52a489ac59 (diff)
downloadsamba-afd6b77bb849bdcfa30513626c61a7aade7d88e2.tar.gz
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 <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit f5735e2c666a5a494131c1d25f7ba5c7fbeae923)
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb/common/io.c10
-rw-r--r--lib/tdb/common/tdb_private.h14
2 files changed, 15 insertions, 9 deletions
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);