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

Unified Diff: src/api.cc

Issue 6674034: Fix Array::New(length) in the API to return an array with the provided length. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 9 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 | « include/v8.h ('k') | src/factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 9e77d31d17b11ebd258b89ba7a2031a723827007..8a8640d33d28aa6565daaccc5a86b945f94036cd 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3960,7 +3960,9 @@ Local<v8::Array> v8::Array::New(int length) {
EnsureInitialized("v8::Array::New()");
LOG_API("Array::New");
ENTER_V8;
- i::Handle<i::JSArray> obj = i::Factory::NewJSArray(length);
+ int real_length = length > 0 ? length : 0;
+ i::Handle<i::JSArray> obj = i::Factory::NewJSArray(real_length);
+ obj->set_length(*i::Factory::NewNumberFromInt(real_length));
return Utils::ToLocal(obj);
}
« no previous file with comments | « include/v8.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698