Skip to content

Commit

Permalink
perform exhaustive search
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Oct 1, 2024
1 parent f5cb7b0 commit ef843be
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions Source/Parser/Functions/RichPresenceAsciiStringLookupFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override bool Evaluate(InterpreterScope scope, out ExpressionBase result)

if (hashedDictionary == null)
{
// could not find key aligned to 4 bytes. try intermediate offsets
// could not find key aligned to 4 bytes. try intermediate offsets. check 16-bit aligned first
for (int i = 2; i < maxLength - 3; i += 4)
{
offset = i;
Expand All @@ -79,14 +79,27 @@ public override bool Evaluate(InterpreterScope scope, out ExpressionBase result)
break;
}

// still no match, try matching the end of the string
// also check unaligned values
if (hashedDictionary == null)
{
length = maxLength & 3;
if (length > 0)
for (int i = 1; i < maxLength - 3; i += 2)
{
offset = maxLength & ~3;
offset = i;
hashedDictionary = BuildHashedDictionary(dictionary, offset, length);

if (hashedDictionary != null)
break;
}

// still no match, try matching the end of the string
if (hashedDictionary == null)
{
length = maxLength & 3;
if (length > 0)
{
offset = maxLength & ~3;
hashedDictionary = BuildHashedDictionary(dictionary, offset, length);
}
}
}
}
Expand Down

0 comments on commit ef843be

Please sign in to comment.