Compare two arrays, but not all bytes if the arrays are large.
| 592 | |
| 593 | // Compare two arrays, but not all bytes if the arrays are large. |
| 594 | static bool LooseMemeq(const uint8_t *A, const uint8_t *B, size_t Size) { |
| 595 | const size_t Limit = 64; |
| 596 | if (Size <= 64) |
| 597 | return !memcmp(A, B, Size); |
| 598 | // Compare first and last Limit/2 bytes. |
| 599 | return !memcmp(A, B, Limit / 2) && |
| 600 | !memcmp(A + Size - Limit / 2, B + Size - Limit / 2, Limit / 2); |
| 601 | } |
| 602 | |
| 603 | // This method is not inlined because it would cause a test to fail where it |
| 604 | // is part of the stack unwinding. See D97975 for details. |
no test coverage detected