1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibJS: Add variant of to_integer_or_infinity() for plain doubles

In many cases we already know a certain value is a number, or don't have
JS values at all and would need to wrap doubles in a value. To optimize
these cases and avoid having to pass a global object into functions that
won't ever allocate or throw, add a standalone implementation of this
function that takes and returns doubles directly.
This commit is contained in:
Linus Groh 2022-05-06 20:17:16 +02:00
parent 875e59b740
commit b9b3d01bea
2 changed files with 30 additions and 0 deletions

View file

@ -431,6 +431,8 @@ bool same_value_zero(Value lhs, Value rhs);
bool same_value_non_numeric(Value lhs, Value rhs);
ThrowCompletionOr<TriState> is_less_than(GlobalObject&, bool left_first, Value lhs, Value rhs);
double to_integer_or_infinity(double);
inline bool Value::operator==(Value const& value) const { return same_value(*this, value); }
}