-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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: fix missing null/undefined check #2195
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1179,3 +1179,7 @@ Buffer.poolSize = ps; | |
assert.throws(function() { | ||
Buffer(10).copy(); | ||
}); | ||
|
||
assert.throws(function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe include an explicit test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to that if we're going with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call |
||
new Buffer(); | ||
}, /must start with number, buffer, array or string/); |
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.
Is
==
faster than checkingnull
andundefined
separately?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.
If we are going to do this, might as well check
!obj
; it's clearer of the intention.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.
But
!obj
will give different error messages with Boolean values, as false value will enter this block.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.
@cjihrig Yes. If you look at the IR produced by Hydrogen it has a single instruction for "check-null-or-undefined".
@Fishrock123
fromObject()
is a catch-all for other values not parsed elsewhere. This is an explicit check for the two following:Everything else will fall through and hit the exception at the bottom of the function.