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

remove unnecessary initialization of buffer #2446

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Jul 25, 2024

It seems unnecessary to initialize a Buffer for non-buffer output encodings and call toString() on an empty string. If I'm not mistaken, any encoding of an empty string, returns an empty string.

The original implementation also has the same exact issue: https://github.com/nodejs/node/blob/82cf0f2f3c9e4c6f9c28cd130e91287d93200373/lib/internal/crypto/hash.js#L161

Node.js fix: nodejs/node#54046

@anonrig anonrig requested a review from jasnell July 25, 2024 20:09
@anonrig anonrig requested review from a team as code owners July 25, 2024 20:09
@anonrig anonrig requested a review from fhanau July 25, 2024 20:09
@anonrig anonrig force-pushed the anonrig/remove-unnecessary-buffer branch from 37e8328 to a4afaa8 Compare July 25, 2024 21:05
@anonrig anonrig force-pushed the anonrig/remove-unnecessary-buffer branch from a4afaa8 to a5f3726 Compare July 25, 2024 21:08
@anonrig anonrig merged commit 27506cc into main Jul 26, 2024
9 checks passed
@anonrig anonrig deleted the anonrig/remove-unnecessary-buffer branch July 26, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants