mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibJS: Add fast path for Uint8ClampedArray Get/Put
These are just like Uint8Array, except Put values have to be clamped in the 0..255 range. Takes CPU usage from 40% to 30% on the "Canvas Cycle" demo at http://www.effectgames.com/demos/canvascycle/ :^)
This commit is contained in:
parent
7abb182fa3
commit
37b5c05ec5
Notes:
sideshowbarker
2024-07-17 05:02:35 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/37b5c05ec5 Pull-request: https://github.com/SerenityOS/serenity/pull/22237
@ -135,6 +135,8 @@ ThrowCompletionOr<Value> get_by_value(VM& vm, Value base_value, Value property_k
|
||||
return fast_integer_indexed_element_get<i16>(typed_array, index);
|
||||
case TypedArrayBase::Kind::Int32Array:
|
||||
return fast_integer_indexed_element_get<i32>(typed_array, index);
|
||||
case TypedArrayBase::Kind::Uint8ClampedArray:
|
||||
return fast_integer_indexed_element_get<u8>(typed_array, index);
|
||||
default:
|
||||
// FIXME: Support more TypedArray kinds.
|
||||
break;
|
||||
@ -423,6 +425,9 @@ ThrowCompletionOr<void> put_by_value(VM& vm, Value base, Value property_key_valu
|
||||
case TypedArrayBase::Kind::Int32Array:
|
||||
fast_integer_indexed_element_set<i32>(typed_array, index, value.as_i32());
|
||||
return {};
|
||||
case TypedArrayBase::Kind::Uint8ClampedArray:
|
||||
fast_integer_indexed_element_set<u8>(typed_array, index, clamp(value.as_i32(), 0, 255));
|
||||
return {};
|
||||
default:
|
||||
// FIXME: Support more TypedArray kinds.
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user