Commit 88376a78 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[OrderedHashSet] Remove redundant hash to bucket

Bug: v8:5717
Change-Id: I88e1e3089844b0955f0f7a6a792c2e10949a5b18
Reviewed-on: https://chromium-review.googlesource.com/480927Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44707}
parent 635eea88
......@@ -18870,7 +18870,8 @@ bool OrderedHashTable<Derived, entrysize>::HasKey(Handle<Derived> table,
Handle<OrderedHashSet> OrderedHashSet::Add(Handle<OrderedHashSet> table,
Handle<Object> key) {
int hash = Object::GetOrCreateHash(table->GetIsolate(), key)->value();
int previous_entry = table->HashToEntry(hash);
int bucket = table->HashToBucket(hash);
int previous_entry = table->HashToEntry(hash, bucket);
int entry = previous_entry;
// Walk the chain of the bucket and try finding the key.
while (entry != kNotFound) {
......@@ -18882,7 +18883,6 @@ Handle<OrderedHashSet> OrderedHashSet::Add(Handle<OrderedHashSet> table,
table = OrderedHashSet::EnsureGrowable(table);
// Read the existing bucket values.
int bucket = table->HashToBucket(hash);
int nof = table->NumberOfElements();
// Insert a new entry at the end,
int new_entry = nof + table->NumberOfDeletedElements();
......
......@@ -410,17 +410,18 @@ class OrderedHashTable : public FixedArray {
int HashToBucket(int hash) { return hash & (NumberOfBuckets() - 1); }
int HashToEntry(int hash) {
int bucket = HashToBucket(hash);
int HashToEntry(int hash, int bucket) {
Object* entry = this->get(kHashTableStartIndex + bucket);
return Smi::cast(entry)->value();
}
int KeyToFirstEntry(Isolate* isolate, Object* key) {
Object* hash = key->GetHash();
Object* hash_obj = key->GetHash();
// If the object does not have an identity hash, it was never used as a key
if (hash->IsUndefined(isolate)) return kNotFound;
return HashToEntry(Smi::cast(hash)->value());
if (hash_obj->IsUndefined(isolate)) return kNotFound;
int hash = Smi::cast(hash_obj)->value();
int bucket = HashToBucket(hash);
return HashToEntry(hash, bucket);
}
int NextChainEntry(int entry) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment