Skip to content

Commit 97c4033

Browse files
Lyall Suntniessen
Lyall Sun
authored andcommitted
readline: remove the caching variable
Line 486 and 525 contain for loops where a length property is cached in a variable (for example, itemLen). This used to be a performance optimization, but current V8 handles the optimization internally. These caching variables are removed, and the length property is used directly instead. PR-URL: #14275 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent 438c877 commit 97c4033

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/readline.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ Interface.prototype._tabComplete = function(lastKeypressWasTab) {
482482
maxColumns = 1;
483483
}
484484
var group = [];
485-
for (var i = 0, compLen = completions.length; i < compLen; i++) {
485+
for (var i = 0; i < completions.length; i++) {
486486
var c = completions[i];
487487
if (c === '') {
488488
handleGroup(self, group, width, maxColumns);
@@ -521,7 +521,7 @@ function handleGroup(self, group, width, maxColumns) {
521521
var item = group[idx];
522522
self._writeToOutput(item);
523523
if (col < maxColumns - 1) {
524-
for (var s = 0, itemLen = item.length; s < width - itemLen; s++) {
524+
for (var s = 0; s < width - item.length; s++) {
525525
self._writeToOutput(' ');
526526
}
527527
}

0 commit comments

Comments
 (0)