Skip to content

Commit 27085bf

Browse files
zertoshrvagg
authored andcommitted
module: remove unnecessary JSON.stringify
`debuglog` uses `%j` as a placeholder for replacement with `JSON.stringify`. So that `JSON.stringify` is only called when the appropriate debug flag is on. The other `%s` changes are for style consistency. PR-URL: #3578 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent feffea0 commit 27085bf

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/module.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ Module._resolveLookupPaths = function(request, parent) {
254254
id = './' + id;
255255
}
256256

257-
debug('RELATIVE: requested:' + request +
258-
' set ID to: ' + id + ' from ' + parent.id);
257+
debug('RELATIVE: requested: %s set ID to: %s from %s', request, id,
258+
parent.id);
259259

260260
return [id, [path.dirname(parent.filename)]];
261261
};
@@ -270,7 +270,7 @@ Module._resolveLookupPaths = function(request, parent) {
270270
// object.
271271
Module._load = function(request, parent, isMain) {
272272
if (parent) {
273-
debug('Module._load REQUEST ' + (request) + ' parent: ' + parent.id);
273+
debug('Module._load REQUEST %s parent: %s', request, parent.id);
274274
}
275275

276276
// REPL is a special case, because it needs the real require.
@@ -292,7 +292,7 @@ Module._load = function(request, parent, isMain) {
292292
}
293293

294294
if (NativeModule.nonInternalExists(filename)) {
295-
debug('load native module ' + request);
295+
debug('load native module %s', request);
296296
return NativeModule.require(filename);
297297
}
298298

@@ -329,8 +329,7 @@ Module._resolveFilename = function(request, parent) {
329329
var paths = resolvedModule[1];
330330

331331
// look up the filename first, since that's the cache key.
332-
debug('looking for ' + JSON.stringify(id) +
333-
' in ' + JSON.stringify(paths));
332+
debug('looking for %j in %j', id, paths);
334333

335334
var filename = Module._findPath(request, paths);
336335
if (!filename) {
@@ -344,8 +343,7 @@ Module._resolveFilename = function(request, parent) {
344343

345344
// Given a file name, pass it to the proper extension handler.
346345
Module.prototype.load = function(filename) {
347-
debug('load ' + JSON.stringify(filename) +
348-
' for module ' + JSON.stringify(this.id));
346+
debug('load %j for module %j', filename, this.id);
349347

350348
assert(!this.loaded);
351349
this.filename = filename;

0 commit comments

Comments
 (0)