From 5106ce789771fafb4e3ea7faa2262fbf276753cd Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 19 Nov 2014 05:49:42 +0000 Subject: Remove StringMap::GetOrCreateValue in favor of StringMap::insert Having two ways to do this doesn't seem terribly helpful and consistently using the insert version (which we already has) seems like it'll make the code easier to understand to anyone working with standard data structures. (I also updated many references to the Entry's key and value to use first() and second instead of getKey{Data,Length,} and get/setValue - for similar consistency) Also removes the GetOrCreateValue functions so there's less surface area to StringMap to fix/improve/change/accommodate move semantics, etc. llvm-svn: 222319 --- llvm/unittests/ADT/StringMapTest.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'llvm/unittests/ADT/StringMapTest.cpp') diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp index af9b6115f85..33d668fe2dd 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -250,7 +250,7 @@ struct StringMapTestStruct { TEST_F(StringMapTest, NonDefaultConstructable) { StringMap t; - t.GetOrCreateValue("Test", StringMapTestStruct(123)); + t.insert(std::make_pair("Test", StringMapTestStruct(123))); StringMap::iterator iter = t.find("Test"); ASSERT_NE(iter, t.end()); ASSERT_EQ(iter->second.i, 123); @@ -278,15 +278,13 @@ private: TEST_F(StringMapTest, MoveOnly) { StringMap t; - t.GetOrCreateValue("Test", MoveOnly(42)); + t.insert(std::make_pair("Test", MoveOnly(42))); StringRef Key = "Test"; StringMapEntry::Create(Key, MoveOnly(42)) ->Destroy(); } TEST_F(StringMapTest, CtorArg) { - StringMap t; - t.GetOrCreateValue("Test", Immovable()); StringRef Key = "Test"; StringMapEntry::Create(Key, Immovable()) ->Destroy(); @@ -294,7 +292,7 @@ TEST_F(StringMapTest, CtorArg) { TEST_F(StringMapTest, MoveConstruct) { StringMap A; - A.GetOrCreateValue("x", 42); + A["x"] = 42; StringMap B = std::move(A); ASSERT_EQ(A.size(), 0u); ASSERT_EQ(B.size(), 1u); @@ -339,7 +337,7 @@ struct Countable { TEST_F(StringMapTest, MoveDtor) { int InstanceCount = 0; StringMap A; - A.GetOrCreateValue("x", Countable(42, InstanceCount)); + A.insert(std::make_pair("x", Countable(42, InstanceCount))); ASSERT_EQ(InstanceCount, 1); auto I = A.find("x"); ASSERT_NE(I, A.end()); -- cgit v1.2.3