mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01: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
|
|
@ -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…
Reference in New Issue
Block a user