diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2019-02-15 17:39:58 +0000 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2019-02-15 14:37:45 -0800 |
commit | 90b7a08aaf189824ec89c99063ae73c0de69fcdf (patch) | |
tree | f9bb4c92a8df6d34a827348335bf0edf52e4a38f /tools/aapt2/StringPool.cpp | |
parent | 29405ed8c501f50247e7e4012b6da80bf51eb3b1 (diff) |
Revert "Fix loaded apk string pool order"
This reverts commit 4e9a922ede24f7f7bfe793321f7328623ee2a061.
Reason for revert: <b/122518436>
Change-Id: I3650b2c6c9bdfa69a3034f9ca49e95a9698c3cdd
Diffstat (limited to 'tools/aapt2/StringPool.cpp')
-rw-r--r-- | tools/aapt2/StringPool.cpp | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/tools/aapt2/StringPool.cpp b/tools/aapt2/StringPool.cpp index a8c26668b3a5..8eabd3225d87 100644 --- a/tools/aapt2/StringPool.cpp +++ b/tools/aapt2/StringPool.cpp @@ -165,13 +165,12 @@ StringPool::Ref StringPool::MakeRef(const StringPiece& str) { return MakeRefImpl(str, Context{}, true); } -StringPool::Ref StringPool::MakeRef(const StringPiece& str, const Context& context, - Maybe<size_t> index) { - return MakeRefImpl(str, context, true, index); +StringPool::Ref StringPool::MakeRef(const StringPiece& str, const Context& context) { + return MakeRefImpl(str, context, true); } StringPool::Ref StringPool::MakeRefImpl(const StringPiece& str, const Context& context, - bool unique, Maybe<size_t> index) { + bool unique) { if (unique) { auto range = indexed_strings_.equal_range(str); for (auto iter = range.first; iter != range.second; ++iter) { @@ -181,26 +180,15 @@ StringPool::Ref StringPool::MakeRefImpl(const StringPiece& str, const Context& c } } - const size_t size = strings_.size(); - // Insert the string at the end of the string vector if no index is specified - const size_t insertion_index = index ? index.value() : size; - std::unique_ptr<Entry> entry(new Entry()); entry->value = str.to_string(); entry->context = context; - entry->index_ = insertion_index; + entry->index_ = strings_.size(); entry->ref_ = 0; entry->pool_ = this; Entry* borrow = entry.get(); - if (insertion_index == size) { - strings_.emplace_back(std::move(entry)); - } else { - // Allocate enough space for the string at the index - strings_.resize(std::max(insertion_index + 1, size)); - strings_[insertion_index] = std::move(entry); - } - + strings_.emplace_back(std::move(entry)); indexed_strings_.insert(std::make_pair(StringPiece(borrow->value), borrow)); return Ref(borrow); } |