Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some explicit (Mutable)ArrayRef constructions #4238

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions common/hashing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,11 @@ TEST(HashingTest, BasicStrings) {

TEST(HashingTest, ArrayLike) {
int c_array[] = {1, 2, 3, 4};
llvm::ArrayRef arr = c_array;
EXPECT_THAT(HashValue(c_array), Eq(HashValue(arr)));
EXPECT_THAT(HashValue(std::array{1, 2, 3, 4}), Eq(HashValue(arr)));
EXPECT_THAT(HashValue(std::vector{1, 2, 3, 4}), Eq(HashValue(arr)));
EXPECT_THAT(HashValue(c_array), Eq(HashValue(c_array)));
EXPECT_THAT(HashValue(std::array{1, 2, 3, 4}), Eq(HashValue(c_array)));
EXPECT_THAT(HashValue(std::vector{1, 2, 3, 4}), Eq(HashValue(c_array)));
EXPECT_THAT(HashValue(llvm::SmallVector<int>{1, 2, 3, 4}),
Eq(HashValue(arr)));
Eq(HashValue(c_array)));
}

TEST(HashingTest, HashAPInt) {
Expand Down Expand Up @@ -700,7 +699,7 @@ auto ExpectNoHashCollisions(llvm::ArrayRef<HashedString> hashes) -> void {

TEST(HashingTest, Collisions1ByteSized) {
auto hashes_storage = AllByteStringsHashedAndSorted<1>();
auto hashes = llvm::ArrayRef(hashes_storage);
llvm::ArrayRef hashes = hashes_storage;
ExpectNoHashCollisions(hashes);

auto low_32bit_collisions = FindBitRangeCollisions<0, 32>(hashes);
Expand All @@ -725,7 +724,7 @@ TEST(HashingTest, Collisions1ByteSized) {

TEST(HashingTest, Collisions2ByteSized) {
auto hashes_storage = AllByteStringsHashedAndSorted<2>();
auto hashes = llvm::ArrayRef(hashes_storage);
llvm::ArrayRef hashes = hashes_storage;
ExpectNoHashCollisions(hashes);

auto low_32bit_collisions = FindBitRangeCollisions<0, 32>(hashes);
Expand Down Expand Up @@ -855,7 +854,7 @@ TYPED_TEST_SUITE(SparseHashTest, SparseHashTestParams);

TYPED_TEST(SparseHashTest, Collisions) {
auto hashes_storage = this->GetHashedByteStrings();
auto hashes = llvm::ArrayRef(hashes_storage);
llvm::ArrayRef hashes = hashes_storage;
ExpectNoHashCollisions(hashes);

int min_7bit_collisions = llvm::NextPowerOf2(hashes.size() - 1) / (1 << 7);
Expand Down
2 changes: 1 addition & 1 deletion common/raw_hashtable_metadata_group_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static auto BuildBenchMetadata() -> llvm::ArrayRef<BenchMetadata> {

for (ssize_t g_index : llvm::seq<ssize_t>(0, BenchSize)) {
// Start by filling the group with random bytes.
auto group_bytes = llvm::MutableArrayRef(
llvm::MutableArrayRef group_bytes(
&metadata_storage[bm_index][g_index * GroupSize], GroupSize);
for (uint8_t& b : group_bytes) {
b = absl::Uniform<uint8_t>(gen) | MetadataGroup::PresentMask;
Expand Down
3 changes: 1 addition & 2 deletions toolchain/driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,7 @@ auto Driver::Compile(const CompileOptions& options,
}
}
CARBON_VLOG() << "*** Check::CheckParseTrees ***\n";
Check::CheckParseTrees(llvm::MutableArrayRef(check_units),
options.prelude_import, vlog_stream_);
Check::CheckParseTrees(check_units, options.prelude_import, vlog_stream_);
CARBON_VLOG() << "*** Check::CheckParseTrees done ***\n";
for (auto& unit : units) {
if (unit->has_source()) {
Expand Down
Loading