-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
crypto: refactor array buffer view validation #29683
Conversation
This is just a refactoring to reduce code and computational overhead.
@@ -164,7 +150,8 @@ Cipher.prototype.update = function update(data, inputEncoding, outputEncoding) { | |||
outputEncoding = outputEncoding || encoding; | |||
|
|||
if (typeof data !== 'string' && !isArrayBufferView(data)) { | |||
throw invalidArrayBufferView('data', data); | |||
throw new ERR_INVALID_ARG_TYPE( | |||
'data', ['string', 'Buffer', 'TypedArray', 'DataView'], data); |
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.
@nodejs/crypto all other cases that validate the input like that convert strings to buffers before passing the data on. Is it intentional, that this is not done here?
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.
@BridgeAR Should we pull the author ready
label until we get an answer for this question? Or are you comfortable landing as-is?
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.
I am comfortable to land this as-is. It's mainly about consistency and the behavior is not changed with this PR.
CI passed, if that encourages anyone to take a closer look. |
Removed |
Also: Should this be benchmarked? |
@Trott this should not have any real performance impact. It might actually be faster due to some redundant typeof checks being removed. |
This is just a refactoring to reduce code and computational overhead. PR-URL: #29683 Reviewed-By: James M Snell <[email protected]>
Landed in eb05d68 |
This is just a refactoring to reduce code and computational overhead. PR-URL: #29683 Reviewed-By: James M Snell <[email protected]>
This is just a refactoring to reduce code and computational overhead.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes