mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Add OutputMemoryStream::fill_to_end.
This commit is contained in:
parent
83d0803861
commit
c8ed882b8e
Notes:
sideshowbarker
2024-07-19 02:38:22 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/c8ed882b8ec Pull-request: https://github.com/SerenityOS/serenity/pull/3496
2 changed files with 11 additions and 3 deletions
|
@ -186,6 +186,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
size_t fill_to_end(u8 value)
|
||||
{
|
||||
const auto nwritten = m_bytes.slice(m_offset).fill(value);
|
||||
m_offset += nwritten;
|
||||
return nwritten;
|
||||
}
|
||||
|
||||
ReadonlyBytes bytes() const { return { data(), size() }; }
|
||||
Bytes bytes() { return { data(), size() }; }
|
||||
|
||||
|
|
|
@ -165,11 +165,12 @@ public:
|
|||
return TypedTransfer<typename RemoveConst<T>::Type>::copy(other.data(), data(), count);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void fill(const T& value)
|
||||
ALWAYS_INLINE size_t fill(const T& value)
|
||||
{
|
||||
for (size_t idx = 0; idx < size(); ++idx) {
|
||||
for (size_t idx = 0; idx < size(); ++idx)
|
||||
data()[idx] = value;
|
||||
}
|
||||
|
||||
return size();
|
||||
}
|
||||
|
||||
bool contains_slow(const T& value) const
|
||||
|
|
Loading…
Reference in a new issue