mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 21:26:22 +00:00
LibJS: Add a fast-path to <Int32>.to_uint8()
This was showing up in a profile as hot.
This commit is contained in:
parent
e47fceed38
commit
4e2845847b
Notes:
github-actions[bot]
2025-08-08 10:56:11 +00:00
Author: https://github.com/alimpfard
Commit: 4e2845847b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5060
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/R-Goc
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/gmta
1 changed files with 5 additions and 0 deletions
|
@ -1050,6 +1050,11 @@ ThrowCompletionOr<i8> Value::to_i8(VM& vm) const
|
|||
// 7.1.11 ToUint8 ( argument ), https://tc39.es/ecma262/#sec-touint8
|
||||
ThrowCompletionOr<u8> Value::to_u8(VM& vm) const
|
||||
{
|
||||
// OPTIMIZATION: Fast path for the common case of an int32.
|
||||
if (is_int32()) {
|
||||
return static_cast<u8>(as_i32() & NumericLimits<u8>::max());
|
||||
}
|
||||
|
||||
// 1. Let number be ? ToNumber(argument).
|
||||
double number = TRY(to_number(vm)).as_double();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue