process_wrap: omit superfluous Number creation
authorBen Noordhuis <info@bnoordhuis.nl>
Tue, 6 Aug 2013 15:42:28 +0000 (17:42 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 6 Aug 2013 15:51:22 +0000 (17:51 +0200)
Don't create a superfluous Number object, just use the version of
v8::Object::Get() that takes an unsigned int. Convert the index to
unsigned int while we're here.

src/process_wrap.cc

index 7637636..b3671d9 100644 (file)
@@ -86,13 +86,12 @@ class ProcessWrap : public HandleWrap {
                                 uv_process_options_t* options) {
     Local<Array> stdios = js_options
         ->Get(String::NewSymbol("stdio")).As<Array>();
-    int len = stdios->Length();
+    uint32_t len = stdios->Length();
     options->stdio = new uv_stdio_container_t[len];
     options->stdio_count = len;
 
-    for (int i = 0; i < len; i++) {
-      Local<Object> stdio = stdios
-          ->Get(Number::New(static_cast<double>(i))).As<Object>();
+    for (uint32_t i = 0; i < len; i++) {
+      Local<Object> stdio = stdios->Get(i).As<Object>();
       Local<Value> type = stdio->Get(String::NewSymbol("type"));
 
       if (type->Equals(String::NewSymbol("ignore"))) {