Browse Source

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: https://github.com/nodejs/node/pull/3578
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v5.x
Andres Suarez 9 years ago
committed by Rod Vagg
parent
commit
89285db128
  1. 14
      lib/module.js

14
lib/module.js

@ -254,8 +254,8 @@ Module._resolveLookupPaths = function(request, parent) {
id = './' + id; id = './' + id;
} }
debug('RELATIVE: requested:' + request + debug('RELATIVE: requested: %s set ID to: %s from %s', request, id,
' set ID to: ' + id + ' from ' + parent.id); parent.id);
return [id, [path.dirname(parent.filename)]]; return [id, [path.dirname(parent.filename)]];
}; };
@ -270,7 +270,7 @@ Module._resolveLookupPaths = function(request, parent) {
// object. // object.
Module._load = function(request, parent, isMain) { Module._load = function(request, parent, isMain) {
if (parent) { if (parent) {
debug('Module._load REQUEST ' + (request) + ' parent: ' + parent.id); debug('Module._load REQUEST %s parent: %s', request, parent.id);
} }
// REPL is a special case, because it needs the real require. // REPL is a special case, because it needs the real require.
@ -292,7 +292,7 @@ Module._load = function(request, parent, isMain) {
} }
if (NativeModule.nonInternalExists(filename)) { if (NativeModule.nonInternalExists(filename)) {
debug('load native module ' + request); debug('load native module %s', request);
return NativeModule.require(filename); return NativeModule.require(filename);
} }
@ -329,8 +329,7 @@ Module._resolveFilename = function(request, parent) {
var paths = resolvedModule[1]; var paths = resolvedModule[1];
// look up the filename first, since that's the cache key. // look up the filename first, since that's the cache key.
debug('looking for ' + JSON.stringify(id) + debug('looking for %j in %j', id, paths);
' in ' + JSON.stringify(paths));
var filename = Module._findPath(request, paths); var filename = Module._findPath(request, paths);
if (!filename) { if (!filename) {
@ -344,8 +343,7 @@ Module._resolveFilename = function(request, parent) {
// Given a file name, pass it to the proper extension handler. // Given a file name, pass it to the proper extension handler.
Module.prototype.load = function(filename) { Module.prototype.load = function(filename) {
debug('load ' + JSON.stringify(filename) + debug('load %j for module %j', filename, this.id);
' for module ' + JSON.stringify(this.id));
assert(!this.loaded); assert(!this.loaded);
this.filename = filename; this.filename = filename;

Loading…
Cancel
Save