summaryrefslogtreecommitdiff
path: root/lib/readline.js
diff options
context:
space:
mode:
authorLyall Sun <lyall.sunlin@gmail.com>2017-07-16 15:24:19 +0800
committerTobias Nießen <tniessen@tnie.de>2017-07-21 15:21:45 +0200
commit97c4033ebf2cf0e67c2ad0ad5dd50ea627d0efae (patch)
tree931b518a2e40a97687c7b1cc1d9265e7c8c443c9 /lib/readline.js
parent438c877fc7e27b48e33f5d412a34d2526dea5842 (diff)
downloadnode-new-97c4033ebf2cf0e67c2ad0ad5dd50ea627d0efae.tar.gz
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 the length property is used directly instead. PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib/readline.js')
-rw-r--r--lib/readline.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/readline.js b/lib/readline.js
index 4998b0678d..b757247e34 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(' ');
}
}