From 3d382f794cec0907ae8422b7e4bcde30e73ac60a Mon Sep 17 00:00:00 2001 From: Lyall Sun Date: Sun, 16 Jul 2017 15:24:19 +0800 Subject: [PATCH] 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. --- lib/readline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index 036a36249588cf..bde2e7016b9388 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -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); @@ -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(' '); } }