Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address the feedback
  • Loading branch information
tarekgh committed Jul 15, 2021
commit 650afa282458ec0c468c3d78f58c4c6e8dbf5b80
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ internal static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char
{
char a = charA;
char b = charB;
char lowSurrogateA = '\0';

if (!char.IsHighSurrogate(a) || index >= lengthA - 1 || !char.IsLowSurrogate(Unsafe.Add(ref charA, 1)))
if (!char.IsHighSurrogate(a) || index >= lengthA - 1 || !char.IsLowSurrogate(lowSurrogateA = Unsafe.Add(ref charA, 1)))
{
if (!char.IsHighSurrogate(b) || index >= lengthB - 1 || !char.IsLowSurrogate(Unsafe.Add(ref charB, 1)))
{
Expand Down Expand Up @@ -245,7 +246,9 @@ internal static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char
// A is Surrogate
//

if (!char.IsHighSurrogate(b) || index >= lengthB - 1 || !char.IsLowSurrogate(Unsafe.Add(ref charB, 1)))
char lowSurrogateB = '\0';

if (!char.IsHighSurrogate(b) || index >= lengthB - 1 || !char.IsLowSurrogate(lowSurrogateB = Unsafe.Add(ref charB, 1)))
{
//
// charB is not surrogate and charA is surrogate
Expand All @@ -258,8 +261,8 @@ internal static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char
// charA and charB are surrogates
//

char lowSurrogateA = Unsafe.Add(ref charA, 1);
char lowSurrogateB = Unsafe.Add(ref charB, 1);
Debug.Assert(lowSurrogateA != '\0');
Debug.Assert(lowSurrogateB != '\0');

if (a == b && lowSurrogateA == lowSurrogateB)
{
Expand Down