From 29dc93298a61e3e344fef5606b59e4cae94e8c2f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 30 Mar 2017 13:21:34 +1300 Subject: [PATCH] ldb_tdb: consistently use ltdb->cache->attribute_indexes to determine if we have indexes This is instead of checking the number of elements via ltdb->cache->indexlist->num_elements In turn, this allows us to avoid fetching ltdb->cache->indexlist in the future Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher Reviewed-by: Garming Sam --- lib/ldb/ldb_tdb/ldb_index.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index fc21bac90bd..46ba725c07f 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -452,6 +452,10 @@ static bool ltdb_is_indexed(struct ldb_module *module, unsigned int i; struct ldb_message_element *el; + if (!ltdb->cache->attribute_indexes) { + return false; + } + el = ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXATTR); if (el == NULL) { return false; @@ -1222,7 +1226,7 @@ static int ltdb_index_add_all(struct ldb_module *module, const char *dn, return LDB_SUCCESS; } - if (ltdb->cache->indexlist->num_elements == 0) { + if (!ltdb->cache->attribute_indexes) { /* no indexed fields */ return LDB_SUCCESS; } @@ -1640,7 +1644,7 @@ int ltdb_reindex(struct ldb_module *module) } /* if we don't have indexes we have nothing todo */ - if (ltdb->cache->indexlist->num_elements == 0) { + if (!ltdb->cache->attribute_indexes) { return LDB_SUCCESS; } -- 2.11.4.GIT