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>
This commit is contained in:
Lyall Sun 2017-07-16 15:24:19 +08:00 committed by Tobias Nießen
parent 438c877fc7
commit 97c4033ebf

View File

@ -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(' ');
}
}