// A simple implementation to compare against. // Note: this version is equivalent to the generic one used when no optimized version is available.
int32_t memcmp16_compare(const uint16_t* s0, const uint16_t* s1, size_t count) { for (size_t i = 0; i < count; i++) { if (s0[i] != s1[i]) { returnstatic_cast<int32_t>(s0[i]) - static_cast<int32_t>(s1[i]);
}
} return0;
}
static constexpr size_t kMemCmp16Rounds = 100000;
staticvoid CheckSeparate(size_t max_length, size_t min_length) {
RandGen r(0x1234);
size_t range_of_tests = 7; // All four (weighted) tests active in the beginning.
for (size_t round = 0; round < kMemCmp16Rounds; ++round) {
size_t type = r.next() % range_of_tests;
size_t count1, count2;
uint16_t *s1, *s2; // Use raw pointers to simplify using clobbered addresses
case4: // random non-zero length of first, second is zero
count1 = (r.next() % max_length) + min_length;
count2 = 0U; break;
case5: // random non-zero length of second, first is zero
count1 = 0U;
count2 = (r.next() % max_length) + min_length; break;
case6: // both zero-length
count1 = 0U;
count2 = 0U;
range_of_tests = 6; // Don't do zero-zero again. break;
default:
ASSERT_TRUE(false) << "Should not get here."; continue;
}
if (count1 > 0U) {
s1 = new uint16_t[count1];
} else { // Leave a random pointer, should not be touched.
s1 = reinterpret_cast<uint16_t*>(0xebad1001);
}
if (count2 > 0U) {
s2 = new uint16_t[count2];
} else { // Leave a random pointer, should not be touched.
s2 = reinterpret_cast<uint16_t*>(0xebad2002);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.