From be07458b11b74e7920097c1c1d997fe29ccc3c1d Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 8 Sep 2016 13:52:32 -0700 Subject: [PATCH] util: don't init Debug if it's not needed yet Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check. PR-URL: https://github.com/nodejs/node/pull/8452 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Evan Lucas --- lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 2d7ba651639..caab2651f35 100644 --- a/lib/util.js +++ b/lib/util.js @@ -289,10 +289,10 @@ function ensureDebugIsInitialized() { function inspectPromise(p) { - ensureDebugIsInitialized(); // Only create a mirror if the object is a Promise. if (!binding.isPromise(p)) return null; + ensureDebugIsInitialized(); const mirror = Debug.MakeMirror(p, true); return {status: mirror.status(), value: mirror.promiseValue().value_}; }