Skip to content

Commit e54f75b

Browse files
Lyall SunFishrock123
Lyall Sun
authored andcommitted
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: #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>
1 parent e237720 commit e54f75b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/readline.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ Interface.prototype._tabComplete = function(lastKeypressWasTab) {
472472
maxColumns = 1;
473473
}
474474
var group = [];
475-
for (var i = 0, compLen = completions.length; i < compLen; i++) {
475+
for (var i = 0; i < completions.length; i++) {
476476
var c = completions[i];
477477
if (c === '') {
478478
handleGroup(self, group, width, maxColumns);
@@ -511,7 +511,7 @@ function handleGroup(self, group, width, maxColumns) {
511511
var item = group[idx];
512512
self._writeToOutput(item);
513513
if (col < maxColumns - 1) {
514-
for (var s = 0, itemLen = item.length; s < width - itemLen; s++) {
514+
for (var s = 0; s < width - item.length; s++) {
515515
self._writeToOutput(' ');
516516
}
517517
}

0 commit comments

Comments
 (0)