summaryrefslogtreecommitdiff
path: root/lib/tdb
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-08-04 18:26:05 +0200
committerJeremy Allison <jra@samba.org>2019-08-06 21:49:27 +0000
commitf5735e2c666a5a494131c1d25f7ba5c7fbeae923 (patch)
tree15887dc0eee7e09b78c6e872219263ea9d29c406 /lib/tdb
parent897bffa8166f643eb9063a848bb0c02455663317 (diff)
downloadsamba-f5735e2c666a5a494131c1d25f7ba5c7fbeae923.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>
Diffstat (limited to 'lib/tdb')
-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);