mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 06:09:08 +00:00
LibJS: Add a fast path for setting valid u32 values in Uint32TypedArray
The exisiting fast path only permits for valid i32 values. On https://cyxx.github.io/another_js, this eliminates the runtime of typed_array_set_element, and reduces the runtime of put_by_value from 11.1% to 7.7%.
This commit is contained in:
parent
d0d22304e4
commit
3d2794d062
Notes:
sideshowbarker
2024-07-17 03:03:37 +09:00
Author: https://github.com/trflynn89
Commit: 3d2794d062
Pull-request: https://github.com/SerenityOS/serenity/pull/23386
Reviewed-by: https://github.com/awesomekling ✅
1 changed files with 9 additions and 0 deletions
|
@ -443,6 +443,15 @@ inline ThrowCompletionOr<void> put_by_value(VM& vm, Value base, Value property_k
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typed_array.kind() == TypedArrayBase::Kind::Uint32Array && value.is_integral_number()) {
|
||||||
|
auto integer = value.as_double();
|
||||||
|
|
||||||
|
if (AK::is_within_range<u32>(integer) && is_valid_integer_index(typed_array, canonical_index)) {
|
||||||
|
fast_typed_array_set_element<u32>(typed_array, index, static_cast<u32>(integer));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (typed_array.kind()) {
|
switch (typed_array.kind()) {
|
||||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
|
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
|
||||||
case TypedArrayBase::Kind::ClassName: \
|
case TypedArrayBase::Kind::ClassName: \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue