summaryrefslogtreecommitdiffstats
path: root/source3/registry
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-02-22 01:11:51 +0100
committerMichael Adam <obnox@samba.org>2009-02-26 11:05:22 +0100
commit5c91cdcc47dc22330839113b37d250b472fb0487 (patch)
tree3f614d4901be427f00ca2b82cc2d187cd5c3d3e4 /source3/registry
parent1b1aac412c1cff1ac969ae07a0fe085b80476c9e (diff)
downloadsamba-5c91cdcc47dc22330839113b37d250b472fb0487.tar.gz
samba-5c91cdcc47dc22330839113b37d250b472fb0487.tar.xz
samba-5c91cdcc47dc22330839113b37d250b472fb0487.zip
Add a comment describing the sorted subkeys
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_backend_db.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index f6471d04eec..344bc4124d3 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -881,6 +881,29 @@ done:
return ret;
}
+/*
+ * regdb_key_exists() is a very frequent operation. It can be quite
+ * time-consuming to fully fetch the parent's subkey list, talloc_strdup all
+ * subkeys and then compare the keyname linearly to all the parent's subkeys.
+ *
+ * The following code tries to make this operation as efficient as possible:
+ * Per registry key we create a list of subkeys that is very efficient to
+ * search for existence of a subkey. Its format is:
+ *
+ * 4 bytes num_subkeys
+ * 4*num_subkey bytes offset into the string array
+ * then follows a sorted list of subkeys in uppercase
+ *
+ * This record is created by create_sorted_subkeys() on demand if it does not
+ * exist. scan_parent_subkeys() uses regdb->parse_record to search the sorted
+ * list, the parsing code and the binary search can be found in
+ * parent_subkey_scanner. The code uses parse_record() to avoid a memcpy of
+ * the potentially large subkey record.
+ *
+ * The sorted subkey record is deleted in regdb_store_keys_internal and
+ * recreated on demand.
+ */
+
static int cmp_keynames(const void *p1, const void *p2)
{
return StrCaseCmp(*((char **)p1), *((char **)p2));