Skip to content
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
Prev Previous commit
[squash] remove indentation for the fast case
  • Loading branch information
addaleax committed May 1, 2017
commit 389af5a8cf12af4762a9afdca07485ee7fa65e76
36 changes: 18 additions & 18 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,28 +569,28 @@ Buffer.prototype.copy = function(target, targetStart, sourceStart, sourceEnd) {
Buffer.prototype.toString = function(encoding, start, end) {
if (arguments.length === 0) {
return this.utf8Slice(0, this.length);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By changing this to return, you can drop the else and save a level of indentation on the rest of the code below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@cjihrig yup, done!

} else {
const len = this.length;
if (len === 0)
return '';
}

if (!start || start < 0)
start = 0;
else if (start >= len)
return '';
const len = this.length;
if (len === 0)
return '';

if (end === undefined || end > len)
end = len;
else if (end <= 0)
return '';
if (!start || start < 0)
start = 0;
else if (start >= len)
return '';

start |= 0;
end |= 0;
if (end === undefined || end > len)
end = len;
else if (end <= 0)
return '';

if (end <= start)
return '';
return stringSlice(this, encoding, start, end);
}
start |= 0;
end |= 0;

if (end <= start)
return '';
return stringSlice(this, encoding, start, end);
};


Expand Down