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

Unified Diff: src/objects.cc

Issue 2827263004: Fix HashTable growth strategy to be 2x instead of 4x (Closed)
Patch Set: update CSA; fix test Created 3 years, 8 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/code-stub-assembler.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index ba56261c9991a48efc3d5f838630c06c058ebae7..0ef4cd2f5e4d6fb37c03e7226a06f5a86669274d 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -16728,21 +16728,19 @@ Handle<Derived> HashTable<Derived, Shape, Key>::EnsureCapacity(
int n,
Key key,
PretenureFlag pretenure) {
+ if (table->HasSufficientCapacityToAdd(n)) return table;
+
Isolate* isolate = table->GetIsolate();
int capacity = table->Capacity();
- int nof = table->NumberOfElements() + n;
-
- if (table->HasSufficientCapacityToAdd(n)) return table;
+ int new_nof = table->NumberOfElements() + n;
const int kMinCapacityForPretenure = 256;
bool should_pretenure = pretenure == TENURED ||
((capacity > kMinCapacityForPretenure) &&
!isolate->heap()->InNewSpace(*table));
- Handle<Derived> new_table = HashTable::New(
- isolate,
- nof * 2,
- USE_DEFAULT_MINIMUM_CAPACITY,
- should_pretenure ? TENURED : NOT_TENURED);
+ Handle<Derived> new_table =
+ HashTable::New(isolate, new_nof, USE_DEFAULT_MINIMUM_CAPACITY,
+ should_pretenure ? TENURED : NOT_TENURED);
table->Rehash(new_table, key);
return new_table;
« no previous file with comments | « src/code-stub-assembler.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698