mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibJS: Return early from parseFloat() if argument is a number
This saves us both a bit of time and accuracy, as Serenity's strtod() still is a little bit off sometimes - and stringifying the result and parsing it again just increases that offset.
This commit is contained in:
parent
088841202d
commit
f06c12173c
1 changed files with 2 additions and 0 deletions
|
@ -153,6 +153,8 @@ Value GlobalObject::is_finite(Interpreter& interpreter)
|
||||||
|
|
||||||
Value GlobalObject::parse_float(Interpreter& interpreter)
|
Value GlobalObject::parse_float(Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
|
if (interpreter.argument(0).is_number())
|
||||||
|
return interpreter.argument(0);
|
||||||
auto string = interpreter.argument(0).to_string(interpreter);
|
auto string = interpreter.argument(0).to_string(interpreter);
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue