diff options
author | Michael Adam <obnox@samba.org> | 2009-02-24 17:51:09 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-02-26 13:22:51 +0100 |
commit | b56f449d6b1cdc527dc553cf0fe774b51a272642 (patch) | |
tree | 7344a8b19080e1539005afb83bdd3bb75f86c173 | |
parent | 6cdcfa3fc14eb25c0da072aa549d06e0c33d4598 (diff) | |
download | samba-b56f449d6b1cdc527dc553cf0fe774b51a272642.tar.gz samba-b56f449d6b1cdc527dc553cf0fe774b51a272642.tar.bz2 samba-b56f449d6b1cdc527dc553cf0fe774b51a272642.zip |
Revert "Fix a O(n^2) algorithm in regdb_fetch_keys()"
This reverts commit a13f065bad0f4d21a67e68b743f17f45bf0a4691.
This fix is reverted, because the speedup is going to move
further down into reg_objects.c. The unsorted list of subkey names
is going to be indexed: This O(n^2) search bites us in more places.
This re-establishes the abstraction of reg_objects.c.
Michael
-rw-r--r-- | source3/registry/reg_backend_db.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 960e884404..02787738fc 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -1166,6 +1166,7 @@ done: int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr) { + WERROR werr; uint32 num_items; uint8 *buf; uint32 buflen, len; @@ -1196,35 +1197,12 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr) buflen = value.dsize; len = tdb_unpack( buf, buflen, "d", &num_items); - /* - * The following code breaks the abstraction that reg_objects.c sets - * up with regsubkey_ctr_addkey(). But if we use that with the current - * data structure of ctr->subkeys being an unsorted array, we end up - * with an O(n^2) algorithm for retrieving keys from the tdb - * file. This is pretty pointless, as we have to trust the data - * structure on disk not to have duplicates anyway. The alternative to - * breaking this abstraction would be to set up a more sophisticated - * data structure in REGSUBKEY_CTR. - * - * This makes "net conf list" for a registry with >1000 shares - * actually usable :-) - */ - - ctr->subkeys = talloc_array(ctr, char *, num_items); - if (ctr->subkeys == NULL) { - DEBUG(5, ("regdb_fetch_keys: could not allocate subkeys\n")); - goto done; - } - ctr->num_subkeys = num_items; - for (i=0; i<num_items; i++) { len += tdb_unpack(buf+len, buflen-len, "f", subkeyname); - ctr->subkeys[i] = talloc_strdup(ctr->subkeys, subkeyname); - if (ctr->subkeys[i] == NULL) { - DEBUG(5, ("regdb_fetch_keys: could not allocate " - "subkeyname\n")); - TALLOC_FREE(ctr->subkeys); - ctr->num_subkeys = 0; + werr = regsubkey_ctr_addkey(ctr, subkeyname); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(5, ("regdb_fetch_keys: regsubkey_ctr_addkey " + "failed: %s\n", win_errstr(werr))); goto done; } } |