mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-09 04:37:52 +03: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
Notes:
sideshowbarker
2024-07-19 06:31:30 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/f06c12173c9 Pull-request: https://github.com/SerenityOS/serenity/pull/2283
@ -153,6 +153,8 @@ Value GlobalObject::is_finite(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);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
|
Loading…
Reference in New Issue
Block a user