Skip to content

Commit

Permalink
readline: remove the caching variable
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Lyall Sun authored and Fishrock123 committed Jul 24, 2017
1 parent e237720 commit e54f75b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ Interface.prototype._tabComplete = function(lastKeypressWasTab) {
maxColumns = 1;
}
var group = [];
for (var i = 0, compLen = completions.length; i < compLen; i++) {
for (var i = 0; i < completions.length; i++) {
var c = completions[i];
if (c === '') {
handleGroup(self, group, width, maxColumns);
Expand Down Expand Up @@ -511,7 +511,7 @@ function handleGroup(self, group, width, maxColumns) {
var item = group[idx];
self._writeToOutput(item);
if (col < maxColumns - 1) {
for (var s = 0, itemLen = item.length; s < width - itemLen; s++) {
for (var s = 0; s < width - item.length; s++) {
self._writeToOutput(' ');
}
}
Expand Down

0 comments on commit e54f75b

Please sign in to comment.