From c430aebe8683699fc072cb87e5be03af370a3f2f Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 30 Nov 2019 11:04:34 +0100 Subject: 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 Reviewed-By: Denys Otrishko Reviewed-By: Rich Trott --- lib/internal/util/inspect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/internal/util') diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 7005911621..4e6f967c6a 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -643,12 +643,12 @@ function formatValue(ctx, value, recurseTimes, typedArray) { const context = value; // Always check for proxies to prevent side effects and to prevent triggering // any proxy handlers. - const proxy = getProxyDetails(value); + const proxy = getProxyDetails(value, !!ctx.showProxy); if (proxy !== undefined) { if (ctx.showProxy) { return formatProxy(ctx, proxy, recurseTimes); } - value = proxy[0]; + value = proxy; } // Provide a hook for user-specified inspect functions. -- cgit v1.2.3