Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Unified Diff: src/ast/ast-value-factory.cc

Issue 2541353002: AstValueFactory: add a cache for one-character strings. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/ast/ast-value-factory.h ('K') | « src/ast/ast-value-factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-value-factory.cc
diff --git a/src/ast/ast-value-factory.cc b/src/ast/ast-value-factory.cc
index ed2976f52a98b15ef6872e9363bd272c6dd7e9e9..6097ff714598e40bba679a48beb401c3194e3cd6 100644
--- a/src/ast/ast-value-factory.cc
+++ b/src/ast/ast-value-factory.cc
@@ -222,6 +222,15 @@ void AstValue::Internalize(Isolate* isolate) {
AstRawString* AstValueFactory::GetOneByteStringInternal(
Vector<const uint8_t> literal) {
+ if (literal.length() == 1 && literal[0] >= 'a' && literal[0] <= 'z') {
Toon Verwaest 2016/12/05 15:30:40 IsInRange(literal[0], 'a', 'z') is faster ;)
marja 2016/12/08 15:09:59 Done.
+ int key = literal[0] - 'a';
+ if (one_character_strings_[key] == nullptr) {
+ uint32_t hash = StringHasher::HashSequentialString<uint8_t>(
Toon Verwaest 2016/12/05 15:30:40 We could just have a-z heapstrings preallocated in
marja 2016/12/08 15:09:59 Hmm yeah, sounds like a good idea to keep the CLs
+ literal.start(), literal.length(), hash_seed_);
+ one_character_strings_[key] = GetString(hash, true, literal);
+ }
+ return one_character_strings_[key];
+ }
uint32_t hash = StringHasher::HashSequentialString<uint8_t>(
literal.start(), literal.length(), hash_seed_);
return GetString(hash, true, literal);
« src/ast/ast-value-factory.h ('K') | « src/ast/ast-value-factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698