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

Unified Diff: Source/bindings/v8/V8Binding.h

Issue 23804006: Leverage the fact that we already know the array size in V8Binding's array converting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8Binding.h
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index f15a1bc7ba703627b1f53c30a62fe8fa7f2ac359..cbcf7b50a3f05822d395aad7e0f32705e455ff8c 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -435,13 +435,14 @@ namespace WebCore {
return Vector<RefPtr<T> >();
Vector<RefPtr<T> > result;
+ result.reserveInitialCapacity(length);
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
for (uint32_t i = 0; i < length; ++i) {
v8::Handle<v8::Value> element = object->Get(i);
if (V8T::HasInstance(element, isolate, worldType(isolate))) {
v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(element);
- result.append(V8T::toNative(elementObject));
+ result.uncheckedAppend(V8T::toNative(elementObject));
} else {
if (success)
*success = false;
@@ -465,10 +466,11 @@ namespace WebCore {
return Vector<T>();
Vector<T> result;
+ result.reserveInitialCapacity(length);
typedef NativeValueTraits<T> TraitsType;
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
for (uint32_t i = 0; i < length; ++i)
- result.append(TraitsType::nativeValue(object->Get(i)));
+ result.uncheckedAppend(TraitsType::nativeValue(object->Get(i)));
return result;
}
@@ -479,8 +481,9 @@ namespace WebCore {
Vector<T> result;
typedef NativeValueTraits<T> TraitsType;
int length = args.Length();
+ result.reserveInitialCapacity(length);
for (int i = startIndex; i < length; ++i)
- result.append(TraitsType::nativeValue(args[i]));
+ result.uncheckedAppend(TraitsType::nativeValue(args[i]));
return result;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698