OSDN Git Service

Revert "AAPT: Modified StringPool uniqueness detection"
authorRyan Mitchell <rtmitchell@google.com>
Mon, 16 Apr 2018 18:21:14 +0000 (18:21 +0000)
committerRyan Mitchell <rtmitchell@google.com>
Mon, 16 Apr 2018 18:21:14 +0000 (18:21 +0000)
This reverts commit 35ecb89a8aa68f24d2e991df5bb9964ad15075dc.

Reason for revert: <Long make duration (infinite loop)>

Change-Id: I10d1cf53ca3054d40e23b06368ebaff6af69beab

tools/aapt2/StringPool.cpp
tools/aapt2/StringPool_test.cpp

index 73a8259..b0ce9e1 100644 (file)
@@ -172,10 +172,9 @@ StringPool::Ref StringPool::MakeRef(const StringPiece& str, const Context& conte
 StringPool::Ref StringPool::MakeRefImpl(const StringPiece& str, const Context& context,
                                         bool unique) {
   if (unique) {
-    for (auto& indexed_str : indexed_strings_) {
-      if (str == indexed_str.first && context.priority == indexed_str.second->context.priority) {
-        return Ref(indexed_str.second);
-      }
+    auto iter = indexed_strings_.find(str);
+    if (iter != std::end(indexed_strings_)) {
+      return Ref(iter->second);
     }
   }
 
index 5f7d3d6..58a03de 100644 (file)
@@ -61,17 +61,6 @@ TEST(StringPoolTest, DoNotInsertNewDuplicateString) {
   EXPECT_THAT(pool.size(), Eq(1u));
 }
 
-TEST(StringPoolTest, DoNotDedupeSameStringDifferentPriority) {
-  StringPool pool;
-
-  StringPool::Ref ref_a = pool.MakeRef("wut", StringPool::Context(1));
-  StringPool::Ref ref_b = pool.MakeRef("wut", StringPool::Context(2));
-
-  EXPECT_THAT(*ref_a, Eq("wut"));
-  EXPECT_THAT(*ref_b, Eq("wut"));
-  EXPECT_THAT(pool.size(), Eq(2u));
-}
-
 TEST(StringPoolTest, MaintainInsertionOrderIndex) {
   StringPool pool;
 
@@ -303,6 +292,7 @@ TEST(StringPoolTest, Flatten) {
   }
 }
 
+
 TEST(StringPoolTest, MaxEncodingLength) {
   StdErrDiagnostics diag;
   using namespace android;  // For NO_ERROR on Windows.