Skip to content

Conversation

BridgeAR
Copy link
Member

This refactors some code for simplicity. It also removes a call
indirection used in the buffers custom inspect function.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

This refactors some code for simplicity. It also removes a call
indirection used in the buffers custom inspect function.
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

LGTM except for one question

}

const len = this.length;
if (len === 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this optimization removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will be detected below with the if (end <= start) check and it seemed an unnecessary check for the average case without hurting much in the empty buffer case.

Buffer.prototype.toString = function toString(encoding, start, end) {
if (arguments.length === 0) {
return this.utf8Slice(0, this.length);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: can this also be indented correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

This seems correct? It's indented by exactly two spaces.

@BridgeAR
Copy link
Member Author

BridgeAR commented Dec 23, 2018

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 23, 2018
@BridgeAR
Copy link
Member Author

Landed in 65d8179

@BridgeAR BridgeAR closed this Dec 24, 2018
BridgeAR added a commit to BridgeAR/node that referenced this pull request Dec 24, 2018
This refactors some code for simplicity. It also removes a call
indirection used in the buffers custom inspect function.

PR-URL: nodejs#25151
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Masashi Hirano <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 25, 2018
This refactors some code for simplicity. It also removes a call
indirection used in the buffers custom inspect function.

PR-URL: #25151
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Masashi Hirano <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 25, 2018
MylesBorins pushed a commit that referenced this pull request Dec 26, 2018
This refactors some code for simplicity. It also removes a call
indirection used in the buffers custom inspect function.

PR-URL: #25151
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Masashi Hirano <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
This refactors some code for simplicity. It also removes a call
indirection used in the buffers custom inspect function.

PR-URL: nodejs#25151
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Masashi Hirano <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@BridgeAR BridgeAR deleted the simplify-buffer-code branch January 20, 2020 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants