-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
buffer: simplify code #25151
Conversation
This refactors some code for simplicity. It also removes a call indirection used in the buffers custom inspect function.
There was a problem hiding this 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
@@ -637,21 +638,18 @@ Buffer.prototype.toString = function toString(encoding, start, end) { | |||
} | |||
|
|||
const len = this.length; | |||
if (len === 0) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { | |||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Landed in 65d8179 |
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This refactors some code for simplicity. It also removes a call
indirection used in the buffers custom inspect function.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes