-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add bunch of nitpicky micro-optimizations #17967
base: main
Are you sure you want to change the base?
Conversation
@@ -299,6 +299,12 @@ static WebCore::BufferEncodingType parseEncoding(JSC::ThrowScope& scope, JSC::JS | |||
uint32_t validateOffset(JSC::ThrowScope& scope, JSC::JSGlobalObject* globalObject, JSC::JSValue value, JSC::JSValue name, uint32_t min, uint32_t max) | |||
{ | |||
if (UNLIKELY(!value.isNumber())) return Bun::ERR::INVALID_ARG_TYPE(scope, globalObject, name, "number"_s, value); | |||
if (value.isInt32()) { |
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 (value.isInt32()) { | |
if (LIKELY(value.isInt32())) { |
@@ -308,6 +314,12 @@ uint32_t validateOffset(JSC::ThrowScope& scope, JSC::JSGlobalObject* globalObjec | |||
uint32_t validateOffset(JSC::ThrowScope& scope, JSC::JSGlobalObject* globalObject, JSC::JSValue value, WTF::ASCIILiteral name, uint32_t min, uint32_t max) | |||
{ | |||
if (UNLIKELY(!value.isNumber())) return Bun::ERR::INVALID_ARG_TYPE(scope, globalObject, name, "number"_s, value); | |||
if (value.isInt32()) { |
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 (value.isInt32()) { | |
if (LIKELY(value.isInt32())) { |
ASSERT_WITH_MESSAGE(upper.isInt32(), "upper must be an integer. Make sure constants set it to a jsNumber()."); | ||
auto lower_num = lower.asInt32(); | ||
auto upper_num = upper.asInt32(); | ||
if (number_num < lower_num || number_num > upper_num) { |
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 (number_num < lower_num || number_num > upper_num) { | |
if (UNLIKELY(number_num < lower_num || number_num > upper_num)) { |
auto minLength_num = minLength.toNumber(globalObject); | ||
RETURN_IF_EXCEPTION(scope, {}); | ||
if (length_num < minLength_num) { | ||
if (length < minLength_num) { |
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 (length < minLength_num) { | |
if (UNLIKELY(length < minLength_num)) { |
auto minLength_num = minLength.toNumber(globalObject); | ||
RETURN_IF_EXCEPTION(scope, {}); | ||
if (length_num < minLength_num) { | ||
if (length < minLength_num) { |
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 (length < minLength_num) { | |
if (UNLIKELY(length < minLength_num)) { |
What does this PR do?
Add bunch of nitpicky micro-optimizations
How did you verify your code works?