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

Unified Diff: src/factory.cc

Issue 2760413002: Minor optimization to v8::internal::Factory::InternalizeOneByteString.
Patch Set: . Created 3 years, 9 months 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
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index e2637ece1e32fd57faf99913c0ca4c5f54746aa1..0d22a3e229098a0aa75befda347bb011df158b3f 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -271,9 +271,27 @@ Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) {
return InternalizeStringWithKey(&key);
}
+namespace {
+
+class OneByteStringKeyExpectingSequential final : public OneByteStringKey {
+ using OneByteStringKey::OneByteStringKey;
+
+ bool IsMatch(Object* string) final {
+ if (V8_LIKELY(StringShape(String::cast(string)).IsSequentialOneByte())) {
+ SeqOneByteString* seq_one_byte = SeqOneByteString::cast(string);
+ return seq_one_byte->length() == string_.length() &&
+ memcmp(seq_one_byte->GetChars(), string_.start(),
+ string_.length()) == 0;
+ }
+ return OneByteStringKey::IsMatch(string);
+ }
+};
+
+} // namespace
Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) {
- OneByteStringKey key(string, isolate()->heap()->HashSeed());
+ OneByteStringKeyExpectingSequential key(string,
+ isolate()->heap()->HashSeed());
return InternalizeStringWithKey(&key);
}
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698