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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent e237720 commit e54f75b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/readline.js

+2-2
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)