Skip to content

Commit

Permalink
Use SequenceEqual in win32 GetFullPath (#10706)
Browse files Browse the repository at this point in the history
* Use SequenceEqual in win32 GetFullPath

This should be slightly more efficient since it's vectorizable.

* fixup! Use SequenceEqual in win32 GetFullPath
  • Loading branch information
rainersigwald authored Oct 2, 2024
1 parent ef6d9ad commit c034fa1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Framework/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ private static unsafe int GetFullPathWin32(string target, int bufferLength, char
/// <returns>True only if the contents of <paramref name="s"/> and the first <paramref name="len"/> characters in <paramref name="buffer"/> are identical.</returns>
private static unsafe bool AreStringsEqual(char* buffer, int len, string s)
{
#if CLR2COMPATIBILITY
if (len != s.Length)
{
return false;
Expand All @@ -1560,6 +1561,9 @@ private static unsafe bool AreStringsEqual(char* buffer, int len, string s)
}

return true;
#else
return MemoryExtensions.SequenceEqual(new ReadOnlySpan<char>(buffer, len), s.AsSpan());
#endif
}

internal static void VerifyThrowWin32Result(int result)
Expand Down

0 comments on commit c034fa1

Please sign in to comment.