Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: avoid use of arguments #11358

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,12 @@ Buffer.prototype.copy = function(target, targetStart, sourceStart, sourceEnd) {
return binding.copy(this, target, targetStart, sourceStart, sourceEnd);
};

Buffer.prototype.toString = function() {
Buffer.prototype.toString = function(encoding, start, end) {
let result;
if (arguments.length === 0) {
result = this.utf8Slice(0, this.length);
} else {
result = slowToString.apply(this, arguments);
result = slowToString.call(this, encoding, start, end);
Copy link
Member

Choose a reason for hiding this comment

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

This is the only call site for slowToString, maybe we can drop the .call entirely?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will require a bit of editing inside slowToString which assumes it is bound to this, but that's certainly doable.

}
if (result === undefined)
throw new Error('"toString()" failed');
Expand Down