mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 08:44:41 +01:00
Remove some explicit (Mutable)ArrayRef constructions (#4238)
Rely on implicit conversion in call sites and initialization. Removing the explicit conversions is only code simplication. Moving from `auto x = Y(z)` to `Y x = z;` helps ensure that only implicit constructors/conversions are happening (whereas the prior syntax allows explicit conversions) which can help with readability since implicit conversions are generally "less complex"/risky/attention-requiring.
This commit is contained in:
@@ -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) {
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user