From: Stephan Seitz <stephan.seitz@fau.de> `load_init_registry_from_file` usually loads files with sorted keys to optimize for this case we should check for the append/last_subkey case first before continuing with normal binary search. Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=59695 --- server/registry.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/registry.c b/server/registry.c index 91b3265e8f7..199e9a6d4ef 100644 --- a/server/registry.c +++ b/server/registry.c @@ -294,12 +294,15 @@ static struct key *find_subkey( const struct key *key, const struct unicode_str { int i, min, max, res; data_size_t len; + bool first_comparison = true; min = 0; max = key->last_subkey; while (min <= max) { - i = (min + max) / 2; + /* when loading from sorted data, most entries are inserted at the last position */ + i = first_comparison ? max : (min + max) / 2; + first_comparison = false; len = min( key->subkeys[i]->obj.name->len, name->len ); res = memicmp_strW( key->subkeys[i]->obj.name->name, name->str, len ); if (!res) res = key->subkeys[i]->obj.name->len - name->len; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10804