Skip to content

Commit

Permalink
util: don't init Debug if it's not needed yet
Browse files Browse the repository at this point in the history
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: #8452
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
  • Loading branch information
bengl authored and MylesBorins committed Mar 9, 2017
1 parent f854d8c commit 2c84601
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,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_};
}
Expand Down

0 comments on commit 2c84601

Please sign in to comment.