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: simplify code #25151

Closed
wants to merge 1 commit into from
Closed

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

lib/buffer.js Show resolved Hide resolved
@@ -637,21 +638,18 @@ Buffer.prototype.toString = function toString(encoding, start, end) {
}

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.

@@ -637,21 +638,18 @@ Buffer.prototype.toString = function toString(encoding, start, end) {
}
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