[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] private static unsafe bool EqualsHelper(string strA, string strB) { int length = strA.Length; if (length != strB.Length) { return false; } fixed (char* str = ((char*) strA)) { char* chPtr = str; fixed (char* str2 = ((char*) strB)) { char* chPtr2 = str2; char* chPtr3 = chPtr; 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))))) { break; } chPtr3 += 10; chPtr4 += 10; length -= 10; } while (length > 0) { if (*(((int*) chPtr3)) != *(((int*) chPtr4))) { break; } chPtr3 += 2; chPtr4 += 2; length -= 2; } return (length <= 0); } } } |
string 中的比较函数
最新推荐文章于 2023-03-07 09:58:56 发布