mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Add fast path to Value::to_u32() if Value is a positive i32
6.6% speed-up on Kraken's stanford-crypto-aes subtest. :^)
This commit is contained in:
parent
45f8542965
commit
b727f8113f
Notes:
sideshowbarker
2024-07-17 03:51:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b727f8113f Pull-request: https://github.com/SerenityOS/serenity/pull/18105 Reviewed-by: https://github.com/linusg ✅
1 changed files with 4 additions and 0 deletions
|
@ -947,6 +947,10 @@ ThrowCompletionOr<i32> Value::to_i32(VM& vm) const
|
|||
// 7.1.7 ToUint32 ( argument ), https://tc39.es/ecma262/#sec-touint32
|
||||
ThrowCompletionOr<u32> Value::to_u32(VM& vm) const
|
||||
{
|
||||
// OPTIMIZATION: If this value is encoded as a positive i32, return it directly.
|
||||
if (is_int32() && as_i32() >= 0)
|
||||
return as_i32();
|
||||
|
||||
// 1. Let number be ? ToNumber(argument).
|
||||
double number = TRY(to_number(vm)).as_double();
|
||||
|
||||
|
|
Loading…
Reference in a new issue