Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
readline: don't use Function#call()
Browse files Browse the repository at this point in the history
It wasn't necessary.
  • Loading branch information
TooTallNate committed Jul 7, 2012
1 parent 2297d63 commit 8a9e8d6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/readline.js
Expand Up @@ -350,13 +350,13 @@ Interface.prototype._tabComplete = function() {
for (var i = 0, compLen = completions.length; i < compLen; i++) {
c = completions[i];
if (c === '') {
handleGroup.call(self, group, width, maxColumns);
handleGroup(self, group, width, maxColumns);
group = [];
} else {
group.push(c);
}
}
handleGroup.call(self, group, width, maxColumns);
handleGroup(self, group, width, maxColumns);

// If there is a common prefix to all matches, then apply that
// portion.
Expand All @@ -373,8 +373,7 @@ Interface.prototype._tabComplete = function() {
};

// this = Interface instance
function handleGroup(group, width, maxColumns) {
var self = this;
function handleGroup(self, group, width, maxColumns) {
if (group.length == 0) {
return;
}
Expand Down

5 comments on commit 8a9e8d6

@alexyoung
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of interest, what's wrong with using Function.prototype.call here? Is passing around self seen as clearer?

@isaacs
Copy link

@isaacs isaacs commented on 8a9e8d6 Jul 11, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm a little curious as well. This seems a bit unnecessary. (Not suggesting reverting it, of course, since that'd be just as unnecessary ;)

@TooTallNate
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing more than a micro-optimization really. this is essentially just another variable name, it just takes a little more work get set it, and then it was just being set to the self variable immediately anyways. It was bugging me :)

@TooTallNate
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though now I realize there's a dead comment above that handleGroup function :\

@alexyoung
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I find these matters of style interesting ;)

Please sign in to comment.