diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2018-06-19 22:14:31 +0300 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2018-06-22 13:04:20 +0300 |
commit | 7ec6951034658b63f908977caeb83112d77cdf3b (patch) | |
tree | 0ed2589ebbd5d9a4c9a8f2f4943b7757eb199651 /src/inspector_js_api.cc | |
parent | cbe307dc812a9088aa909837b9edd7e728e14953 (diff) |
src: avoid common case heap allocation
Optimize three functions that pass on (part of) their JS arguments to
the JS function they call by stack-allocating the storage in the common
case.
PR-URL: https://github.com/nodejs/node/pull/21409
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/inspector_js_api.cc')
-rw-r--r-- | src/inspector_js_api.cc | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 802029ac4f2..104cd93b3cd 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -131,11 +131,7 @@ void CallAndPauseOnStart(const FunctionCallbackInfo<v8::Value>& args) { Environment* env = Environment::GetCurrent(args); CHECK_GT(args.Length(), 1); CHECK(args[0]->IsFunction()); - std::vector<v8::Local<v8::Value>> call_args; - for (int i = 2; i < args.Length(); i++) { - call_args.push_back(args[i]); - } - + SlicedArguments call_args(args, /* start */ 2); env->inspector_agent()->PauseOnNextJavascriptStatement("Break on start"); v8::MaybeLocal<v8::Value> retval = args[0].As<v8::Function>()->Call(env->context(), args[1], @@ -150,10 +146,7 @@ void InspectorConsoleCall(const FunctionCallbackInfo<Value>& info) { HandleScope handle_scope(isolate); Local<Context> context = isolate->GetCurrentContext(); CHECK_LT(2, info.Length()); - std::vector<Local<Value>> call_args; - for (int i = 3; i < info.Length(); ++i) { - call_args.push_back(info[i]); - } + SlicedArguments call_args(info, /* start */ 3); Environment* env = Environment::GetCurrent(isolate); if (InspectorEnabled(env)) { Local<Value> inspector_method = info[0]; |