summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-10-22 11:16:00 +1100
committerAndrew Tridgell <tridge@samba.org>2009-10-22 12:47:55 +1100
commit129298c9b9793794125558b8334fd5b578ca1112 (patch)
treee6000409165e3ea9d9348bad32860b52f79d3733 /source4/lib/ldb/ldb_tdb
parentd483c3bb960823cbf9a812872d6040bc390c48ca (diff)
downloadsamba-129298c9b9793794125558b8334fd5b578ca1112.tar.gz
samba-129298c9b9793794125558b8334fd5b578ca1112.tar.bz2
samba-129298c9b9793794125558b8334fd5b578ca1112.zip
s4-ldb: over-allocate index records to save on realloc costs
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 501907578d..606c24491c 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -1065,6 +1065,7 @@ static int ltdb_index_add1(struct ldb_module *module, const char *dn,
int ret;
const struct ldb_schema_attribute *a;
struct dn_list *list;
+ unsigned alloc_len;
ldb = ldb_module_get_ctx(module);
@@ -1096,7 +1097,10 @@ static int ltdb_index_add1(struct ldb_module *module, const char *dn,
return LDB_ERR_ENTRY_ALREADY_EXISTS;
}
- list->dn = talloc_realloc(list, list->dn, struct ldb_val, list->count+1);
+ /* overallocate the list a bit, to reduce the number of
+ * realloc trigered copies */
+ alloc_len = ((list->count+1)+7) & ~7;
+ list->dn = talloc_realloc(list, list->dn, struct ldb_val, alloc_len);
if (list->dn == NULL) {
talloc_free(list);
return LDB_ERR_OPERATIONS_ERROR;