mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibIPC: Decode Vector<T> in one swoop for trivial arithmetic types
This avoids having the CPU churn through the vector one little integer at a time.
This commit is contained in:
parent
4d7d8aa827
commit
94fc8c47c0
Notes:
github-actions[bot]
2025-12-01 14:14:06 +00:00
Author: https://github.com/awesomekling
Commit: 94fc8c47c0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6982
Reviewed-by: https://github.com/gmta ✅
1 changed files with 13 additions and 0 deletions
|
|
@ -149,6 +149,7 @@ ErrorOr<T> decode(Decoder& decoder)
|
|||
}
|
||||
|
||||
template<Concepts::Vector T>
|
||||
requires(!IsArithmetic<typename T::ValueType>)
|
||||
ErrorOr<T> decode(Decoder& decoder)
|
||||
{
|
||||
T vector;
|
||||
|
|
@ -164,6 +165,18 @@ ErrorOr<T> decode(Decoder& decoder)
|
|||
return vector;
|
||||
}
|
||||
|
||||
template<Concepts::Vector T>
|
||||
requires(IsArithmetic<typename T::ValueType>)
|
||||
ErrorOr<T> decode(Decoder& decoder)
|
||||
{
|
||||
T vector;
|
||||
auto size = TRY(decoder.decode_size());
|
||||
VERIFY(!Checked<size_t>::multiplication_would_overflow(size, sizeof(typename T::ValueType)));
|
||||
vector.resize(size);
|
||||
TRY(decoder.decode_into({ reinterpret_cast<u8*>(vector.data()), size * sizeof(typename T::ValueType) }));
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<Concepts::HashMap T>
|
||||
ErrorOr<T> decode(Decoder& decoder)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue