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

Unified Diff: src/objects-inl.h

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 | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 0f666d7ec74ab04fe16dc1ff3128236907b64196..71e54081044ceb36a55909c42d9afda6346e4fa1 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -7289,6 +7289,17 @@ inline void StringHasher::AddCharacters(const Char* chars, int length) {
}
}
+uint32_t StringHasher::GetHashField() {
+ if (length_ <= String::kMaxHashCalcLength) {
+ if (is_array_index_) {
+ return MakeArrayIndexHash(array_index_, length_);
+ }
+ return (GetHashCore(raw_running_hash_) << String::kHashShift) |
+ String::kIsNotArrayIndexMask;
+ } else {
+ return (length_ << String::kHashShift) | String::kIsNotArrayIndexMask;
+ }
+}
template <typename schar>
uint32_t StringHasher::HashSequentialString(const schar* chars,
@@ -7707,6 +7718,18 @@ bool AccessorPair::IsJSAccessor(Object* obj) {
return obj->IsCallable() || obj->IsUndefined(GetIsolate());
}
+Handle<String> StringTable::LookupKey(Isolate* isolate, HashTableKey* key) {
+ Handle<StringTable> table = isolate->factory()->string_table();
+ int32_t hash = key->Hash();
+ int entry = table->FindEntry(isolate, key, hash);
+
+ // String already in table.
+ if (entry != kNotFound) {
+ return handle(String::cast(table->KeyAt(entry)), isolate);
+ }
+
+ return InsertKey(isolate, table, key, hash);
+}
template<typename Derived, typename Shape, typename Key>
void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698