Commit 4d0d7e49 authored by Torge Matthies's avatar Torge Matthies Committed by Alexandre Julliard

kernelbase: Reuse the previous iteration's pos and sortkey state if possible in find_substring.

We don't have to reset pos and the sortkey state for every iteration of the for-loop. In most cases the previous iteration's values are still valid, and can be re-used, skipping a lot of duplicate work. Signed-off-by: 's avatarTorge Matthies <tmatthies@codeweavers.com>
parent 01146582
......@@ -3915,9 +3915,9 @@ static int find_substring( const struct sortguid *sortid, DWORD flags, const WCH
for (start = 0; start < srclen; start++)
{
pos = start;
for (len = start + 1; len <= srclen; len++)
{
pos = start;
while (pos < len && s.primary_pos <= val.key_primary.len)
{
while (pos < len && !s.key_primary.len)
......@@ -3933,7 +3933,7 @@ static int find_substring( const struct sortguid *sortid, DWORD flags, const WCH
s.primary_pos += s.key_primary.len;
s.key_primary.len = 0;
}
if (s.primary_pos < val.key_primary.len) goto next;
if (s.primary_pos < val.key_primary.len) continue;
have_extra = remove_unneeded_weights( sortid, &s );
if (compare_sortkeys( &s.key_diacritic, &val.key_diacritic, FALSE )) goto next;
......@@ -3957,6 +3957,7 @@ static int find_substring( const struct sortguid *sortid, DWORD flags, const WCH
s.key_primary.len = s.key_diacritic.len = s.key_case.len = s.key_special.len = 0;
s.key_extra[0].len = s.key_extra[1].len = s.key_extra[2].len = s.key_extra[3].len = 0;
s.primary_pos = 0;
pos = start;
}
if (flags & FIND_STARTSWITH) break;
if (flags & FIND_FROMSTART && found != -1) break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment