Switch deque to forward_list for memory use.

Landing this to test the difference in memory consumption vs deque. If
this doesn't help, we can try a different approach.

Change-Id: I7d0e8a2e694671db7e7627754bc305991fea5b5c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399016
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2021-04-21 09:55:09 -04:00 committed by Skia Commit-Bot
parent 9a56eb7063
commit bf9dff6f51
2 changed files with 5 additions and 7 deletions

View File

@ -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) {

View File

@ -14,7 +14,7 @@
#include "include/private/SkTHash.h"
#include "src/sksl/SkSLErrorReporter.h"
#include <deque>
#include <forward_list>
#include <memory>
#include <vector>
@ -139,8 +139,7 @@ private:
bool fBuiltin = false;
std::vector<std::unique_ptr<IRNode>> fOwnedNodes;
// A deque is used here because insertion is guaranteed not to invalidate the pointers inside.
std::deque<String> fOwnedStrings;
std::forward_list<String> fOwnedStrings;
SkTHashMap<SymbolKey, const Symbol*, SymbolKey::Hash> fSymbols;
ErrorReporter& fErrorReporter;