From 97c4033ebf2cf0e67c2ad0ad5dd50ea627d0efae 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/14275 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Benjamin Gruenbaum Reviewed-By: Timothy Gu Reviewed-By: Colin Ihrig Reviewed-By: Tobias Nießen Reviewed-By: Gireesh Punathil Reviewed-By: Gibson Fahnestock --- lib/readline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index 4998b0678d7..b757247e340 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -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); @@ -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(' '); } }