src: improve startup time
authorEvan Lucas <evanlucas@me.com>
Fri, 21 Aug 2015 09:15:55 +0000 (04:15 -0500)
committerEvan Lucas <evanlucas@me.com>
Fri, 21 Aug 2015 19:13:32 +0000 (14:13 -0500)
Previously, V8:SetFlagsFromCommandLine was being called even if v8_argc
was 0. This change prevents that from being called unless v8 arguments
are actually passed.

Improves startup time by about 5%.

PR-URL: https://github.com/nodejs/node/pull/2483
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
src/node.cc

index e1ca866..ad9184e 100644 (file)
@@ -3706,7 +3706,8 @@ void Init(int* argc,
 #endif
   // The const_cast doesn't violate conceptual const-ness.  V8 doesn't modify
   // the argv array or the elements it points to.
-  V8::SetFlagsFromCommandLine(&v8_argc, const_cast<char**>(v8_argv), true);
+  if (v8_argc != 0)
+    V8::SetFlagsFromCommandLine(&v8_argc, const_cast<char**>(v8_argv), true);
 
   // Anything that's still in v8_argv is not a V8 or a node option.
   for (int i = 1; i < v8_argc; i++) {