-
Notifications
You must be signed in to change notification settings - Fork 43
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
Optimize TypedArrayObject.prototype.set, indexOf, lastIndexOf #1251
Conversation
ksh8281
commented
Sep 11, 2023
•
edited
Loading
edited
- Fix binary precedence bug
Fix #1250 |
src/builtins/BuiltinTypedArray.cpp
Outdated
if (type == TypedArrayType::BigInt64 || type == TypedArrayType::BigUint64) { | ||
if (!value.isBigInt()) { | ||
return Value(-1); | ||
} | ||
} else { | ||
if (!value.isNumber()) { |
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.
What about merging else
and if
to one else if
statement here?
And if these conditions rarely happen, adding UNLIKELY
would be good too.
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.
Good point!
if (type == TypedArrayType::BigInt64 || type == TypedArrayType::BigUint64) { | ||
uint64_t argv0ToUint64 = type == TypedArrayType::BigInt64 ? bitwise_cast<uint64_t>(value.asBigInt()->toInt64()) : value.asBigInt()->toUint64(); | ||
while (compFn(byteK, byteLength)) { | ||
if (*reinterpret_cast<uint64_t*>(&buffer[byteK]) == argv0ToUint64) { |
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 it fine to directly access array elements regardless of Endian?
What if we use BigEndian?
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.
IMO We don't need to care endianness.
because two values are comes from same machine
* Update cmakefile Signed-off-by: Seonghyun Kim <[email protected]>
Signed-off-by: Seonghyun Kim <[email protected]>
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