Skip to content

Instantly share code, notes, and snippets.

@forcewake
Created April 9, 2013 07:03
Show Gist options
  • Save forcewake/5343594 to your computer and use it in GitHub Desktop.
Save forcewake/5343594 to your computer and use it in GitHub Desktop.
int length = strA.Length;
if (length != strB.Length)
return false;
fixed (char* chPtr1 = &strA.m_firstChar)
fixed (char* chPtr2 = &strB.m_firstChar)
{
char* chPtr3 = chPtr1;
char* chPtr4 = chPtr2;
while (length >= 10)
{
if (*(int*)chPtr3 != *(int*)chPtr4 || *(int*)(chPtr3 + 2) != *(int*)(chPtr4 + 2) || (*(int*)(chPtr3 + 4) != *(int*)(chPtr4 + 4) || *(int*)(chPtr3 + 6) != *(int*)(chPtr4 + 6)) || *(int*)(chPtr3 + 8) != *(int*)(chPtr4 + 8))
return false;
chPtr3 += 10;
chPtr4 += 10;
length -= 10;
}
while (length > 0 && *(int*)chPtr3 == *(int*)chPtr4)
{
chPtr3 += 2;
chPtr4 += 2;
length -= 2;
}
return length <= 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment