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

Unified Diff: src/runtime/runtime-object.cc

Issue 1397063002: [runtime] Fancify KeyAccumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding KeyAccumulator destructor Created 5 years, 2 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
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index 3d02572a0e0cae4c6a8ef8defcc932bf035d36eb..12dece522f08610cbc5d903f4818d0f62f3e6530 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -983,11 +983,7 @@ RUNTIME_FUNCTION(Runtime_OwnKeys) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY));
- // Some fast paths through GetKeysInFixedArrayFor reuse a cached
- // property array and since the result is mutable we have to create
- // a fresh clone on each invocation.
int length = contents->length();
- Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length);
int offset = 0;
// Use an outer loop to avoid creating too many handles in the current
// handle scope.
@@ -997,18 +993,16 @@ RUNTIME_FUNCTION(Runtime_OwnKeys) {
int end = Min(offset, length);
for (int i = offset - 100; i < end; i++) {
Object* entry = contents->get(i);
- if (entry->IsString()) {
- copy->set(i, entry);
- } else {
- DCHECK(entry->IsNumber());
- Handle<Object> entry_handle(entry, isolate);
- Handle<Object> entry_str =
- isolate->factory()->NumberToString(entry_handle);
- copy->set(i, *entry_str);
- }
+ if (entry->IsString()) continue;
+
+ DCHECK(entry->IsNumber());
+ Handle<Object> entry_handle(entry, isolate);
+ Handle<Object> entry_str =
+ isolate->factory()->NumberToString(entry_handle);
+ contents->set(i, *entry_str);
}
}
- return *isolate->factory()->NewJSArrayWithElements(copy);
+ return *isolate->factory()->NewJSArrayWithElements(contents);
}

Powered by Google App Engine
This is Rietveld 408576698