diff --git a/src/sksl/ir/SkSLSymbolTable.cpp b/src/sksl/ir/SkSLSymbolTable.cpp index 9d6af7d7e1..da00fd8b88 100644 --- a/src/sksl/ir/SkSLSymbolTable.cpp +++ b/src/sksl/ir/SkSLSymbolTable.cpp @@ -82,10 +82,9 @@ const Symbol* SymbolTable::lookup(SymbolTable* writableSymbolTable, const Symbol } const String* SymbolTable::takeOwnershipOfString(String str) { - fOwnedStrings.push_back(std::move(str)); - // Because fOwnedStrings is a deque and we only push_back new elements onto it, and never erase - // or reorder, returning a pointer to an element here is safe. - return &fOwnedStrings.back(); + fOwnedStrings.push_front(std::move(str)); + // Because fOwnedStrings is a linked list, pointers to elements are stable. + return &fOwnedStrings.front(); } void SymbolTable::addAlias(StringFragment name, const Symbol* symbol) { diff --git a/src/sksl/ir/SkSLSymbolTable.h b/src/sksl/ir/SkSLSymbolTable.h index e3bea7a5c7..3167d792a7 100644 --- a/src/sksl/ir/SkSLSymbolTable.h +++ b/src/sksl/ir/SkSLSymbolTable.h @@ -14,7 +14,7 @@ #include "include/private/SkTHash.h" #include "src/sksl/SkSLErrorReporter.h" -#include +#include #include #include @@ -139,8 +139,7 @@ private: bool fBuiltin = false; std::vector> fOwnedNodes; - // A deque is used here because insertion is guaranteed not to invalidate the pointers inside. - std::deque fOwnedStrings; + std::forward_list fOwnedStrings; SkTHashMap fSymbols; ErrorReporter& fErrorReporter;