diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-07 19:23:56 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-07 19:27:30 +0200 |
commit | e67155638c28863e504b3b709a607f492bb0592e (patch) | |
tree | de558fe290c610c9043b96a00f8d0debdccc369f /Userland/Libraries/LibJS/Runtime/Value.cpp | |
parent | 5b1f6974603248da0d029d5250676a3a7115784f (diff) | |
download | serenity-e67155638c28863e504b3b709a607f492bb0592e.zip |
LibJS: Take advantage of Value::Type::Int32 in a bunch of functions
If a JS::Value has type Int32, we know it's a finite, 32-bit integer.
Use this information to avoid converting it to a double if possible.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Value.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 4415f765d7..7078eb1369 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -580,18 +580,6 @@ u64 Value::to_bigint_uint64(GlobalObject& global_object) const return bigint->big_integer().to_u64(); } -// FIXME: These two conversions are wrong for JS, and seem likely to be footguns -i32 Value::as_i32() const -{ - return static_cast<i32>(as_double()); -} - -u32 Value::as_u32() const -{ - VERIFY(as_double() >= 0); - return (u32)min(as_double(), (double)NumericLimits<u32>::max()); -} - double Value::to_double(GlobalObject& global_object) const { auto number = to_number(global_object); |