Skip to content

Commit 8b92223

Browse files
BridgeARMylesBorins
authored andcommittedDec 17, 2019
repl: simplify code
This simplifies some repl code and removes a code branch that is unreachable. PR-URL: #30907 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent f7eeb8c commit 8b92223

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed
 

‎lib/repl.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ REPLServer.prototype.createContext = function() {
953953
}
954954

955955
const module = new CJSModule('<repl>');
956-
module.paths = CJSModule._resolveLookupPaths('<repl>', parentModule) || [];
956+
module.paths = CJSModule._resolveLookupPaths('<repl>', parentModule);
957957

958958
ObjectDefineProperty(context, 'module', {
959959
configurable: true,
@@ -1307,21 +1307,17 @@ function complete(line, callback) {
13071307
}
13081308
// Works for non-objects
13091309
try {
1310-
let sentinel = 5;
13111310
let p;
13121311
if (typeof obj === 'object' || typeof obj === 'function') {
13131312
p = ObjectGetPrototypeOf(obj);
13141313
} else {
13151314
p = obj.constructor ? obj.constructor.prototype : null;
13161315
}
1317-
while (p !== null) {
1316+
// Circular refs possible? Let's guard against that.
1317+
let sentinel = 5;
1318+
while (p !== null && sentinel-- !== 0) {
13181319
memberGroups.push(filteredOwnPropertyNames(p));
13191320
p = ObjectGetPrototypeOf(p);
1320-
// Circular refs possible? Let's guard against that.
1321-
sentinel--;
1322-
if (sentinel <= 0) {
1323-
break;
1324-
}
13251321
}
13261322
} catch {}
13271323
}

0 commit comments

Comments
 (0)
Please sign in to comment.