Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-11-30 13:04:34 +0300
committerMichaƫl Zasso <targos@protonmail.com>2019-12-09 12:23:11 +0300
commiteeaeb51dccb2539fde69a7a93d06a94d35db6349 (patch)
tree733c924dd0b53e24ffffa269af4c5974cbdd546f /src
parentad4d52d1b51038aacc7fc84dbf06a477b2c65191 (diff)
util: improve performance inspecting proxies
This makes sure we do not retrieve the handler in case it's not required. This improves the performance a tiny bit for these cases. PR-URL: https://github.com/nodejs/node/pull/30767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_util.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index 9c24985a47a..07a7b69dbd9 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -91,15 +91,23 @@ static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) {
if (!args[0]->IsProxy())
return;
+ CHECK(args[1]->IsBoolean());
+
Local<Proxy> proxy = args[0].As<Proxy>();
- Local<Value> ret[] = {
- proxy->GetTarget(),
- proxy->GetHandler()
- };
+ if (args[1]->IsTrue()) {
+ Local<Value> ret[] = {
+ proxy->GetTarget(),
+ proxy->GetHandler()
+ };
- args.GetReturnValue().Set(
- Array::New(args.GetIsolate(), ret, arraysize(ret)));
+ args.GetReturnValue().Set(
+ Array::New(args.GetIsolate(), ret, arraysize(ret)));
+ } else {
+ Local<Value> ret = proxy->GetTarget();
+
+ args.GetReturnValue().Set(ret);
+ }
}
static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {