Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 using the length
property directly instead.
  • Loading branch information
Lyall Sun committed Jul 16, 2017
commit 3d382f794cec0907ae8422b7e4bcde30e73ac60a
4 changes: 2 additions & 2 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,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 @@ -522,7 +522,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