1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

ldb_tdb: Use a binary search to speed up ltdb_dn_list_find_val()

This only works if we have the GUID index format, as otherwise these are unsorted.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2017-08-21 15:51:19 +12:00
parent fdff9a7087
commit b6bf7e7b0b

View File

@ -119,12 +119,30 @@ static int ltdb_dn_list_find_val(struct ltdb_private *ltdb,
const struct ldb_val *v)
{
unsigned int i;
for (i=0; i<list->count; i++) {
if (ldb_val_equal_exact(&list->dn[i], v) == 1) {
return i;
struct ldb_val *exact = NULL, *next = NULL;
if (ltdb->cache->GUID_index_attribute == NULL) {
for (i=0; i<list->count; i++) {
if (ldb_val_equal_exact(&list->dn[i], v) == 1) {
return i;
}
}
return -1;
}
return -1;
BINARY_ARRAY_SEARCH_GTE(list->dn, list->count,
*v, ldb_val_equal_exact_ordered,
exact, next);
if (exact == NULL) {
return -1;
}
/* Not required, but keeps the compiler quiet */
if (next != NULL) {
return -1;
}
i = exact - list->dn;
return i;
}
/*