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 <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
  • Loading branch information
Lyall Sun authored and tniessen committed Jul 21, 2017
1 parent 438c877 commit 97c4033
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 @@ -482,7 +482,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 @@ -521,7 +521,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 97c4033

Please sign in to comment.