|
@@ -592,9 +592,9 @@ auto FindBitRangeCollisions(llvm::ArrayRef<HashedValue<T>> hashes)
|
|
|
|
|
|
|
|
// Now we sort by the extracted bit sequence so we can efficiently scan for
|
|
// Now we sort by the extracted bit sequence so we can efficiently scan for
|
|
|
// colliding bit patterns.
|
|
// colliding bit patterns.
|
|
|
- std::sort(
|
|
|
|
|
- bits_and_indices.begin(), bits_and_indices.end(),
|
|
|
|
|
- [](const auto& lhs, const auto& rhs) { return lhs.bits < rhs.bits; });
|
|
|
|
|
|
|
+ llvm::sort(bits_and_indices, [](const auto& lhs, const auto& rhs) {
|
|
|
|
|
+ return lhs.bits < rhs.bits;
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
// Scan the sorted bit sequences we've extracted looking for collisions. We
|
|
// Scan the sorted bit sequences we've extracted looking for collisions. We
|
|
|
// count the total collisions, but we also track the number of individual
|
|
// count the total collisions, but we also track the number of individual
|
|
@@ -635,16 +635,15 @@ auto FindBitRangeCollisions(llvm::ArrayRef<HashedValue<T>> hashes)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Sort by collision count for each hash.
|
|
// Sort by collision count for each hash.
|
|
|
- std::sort(bits_and_indices.begin(), bits_and_indices.end(),
|
|
|
|
|
- [&](const auto& lhs, const auto& rhs) {
|
|
|
|
|
- return collision_counts[collision_map[lhs.index]] <
|
|
|
|
|
- collision_counts[collision_map[rhs.index]];
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ llvm::sort(bits_and_indices, [&](const auto& lhs, const auto& rhs) {
|
|
|
|
|
+ return collision_counts[collision_map[lhs.index]] <
|
|
|
|
|
+ collision_counts[collision_map[rhs.index]];
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
// And compute the median and max.
|
|
// And compute the median and max.
|
|
|
int median = collision_counts
|
|
int median = collision_counts
|
|
|
[collision_map[bits_and_indices[bits_and_indices.size() / 2].index]];
|
|
[collision_map[bits_and_indices[bits_and_indices.size() / 2].index]];
|
|
|
- int max = *std::max_element(collision_counts.begin(), collision_counts.end());
|
|
|
|
|
|
|
+ int max = *llvm::max_element(collision_counts);
|
|
|
CARBON_CHECK(max ==
|
|
CARBON_CHECK(max ==
|
|
|
collision_counts[collision_map[bits_and_indices.back().index]]);
|
|
collision_counts[collision_map[bits_and_indices.back().index]]);
|
|
|
return {.total = total, .median = median, .max = max};
|
|
return {.total = total, .median = median, .max = max};
|
|
@@ -672,11 +671,9 @@ auto AllByteStringsHashedAndSorted() {
|
|
|
hashes.push_back({HashValue(s, TestSeed), s});
|
|
hashes.push_back({HashValue(s, TestSeed), s});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- std::sort(hashes.begin(), hashes.end(),
|
|
|
|
|
- [](const HashedString& lhs, const HashedString& rhs) {
|
|
|
|
|
- return static_cast<uint64_t>(lhs.hash) <
|
|
|
|
|
- static_cast<uint64_t>(rhs.hash);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ llvm::sort(hashes, [](const HashedString& lhs, const HashedString& rhs) {
|
|
|
|
|
+ return static_cast<uint64_t>(lhs.hash) < static_cast<uint64_t>(rhs.hash);
|
|
|
|
|
+ });
|
|
|
CheckNoDuplicateValues(hashes);
|
|
CheckNoDuplicateValues(hashes);
|
|
|
|
|
|
|
|
return hashes;
|
|
return hashes;
|
|
@@ -832,11 +829,9 @@ struct SparseHashTest : ::testing::Test {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- std::sort(hashes.begin(), hashes.end(),
|
|
|
|
|
- [](const HashedString& lhs, const HashedString& rhs) {
|
|
|
|
|
- return static_cast<uint64_t>(lhs.hash) <
|
|
|
|
|
- static_cast<uint64_t>(rhs.hash);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ llvm::sort(hashes, [](const HashedString& lhs, const HashedString& rhs) {
|
|
|
|
|
+ return static_cast<uint64_t>(lhs.hash) < static_cast<uint64_t>(rhs.hash);
|
|
|
|
|
+ });
|
|
|
CheckNoDuplicateValues(hashes);
|
|
CheckNoDuplicateValues(hashes);
|
|
|
|
|
|
|
|
return hashes;
|
|
return hashes;
|