mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
AK: Override read_until_filled
in FixedMemoryStream
This specialized method allow significant performance improvements for the user.
This commit is contained in:
parent
d00a563462
commit
102fdf6305
Notes:
sideshowbarker
2024-07-17 04:10:16 +09:00
Author: https://github.com/LucasChollet
Commit: 102fdf6305
Pull-request: https://github.com/SerenityOS/serenity/pull/19283
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/kleinesfilmroellchen
Reviewed-by: https://github.com/nico ✅
Reviewed-by: https://github.com/timschumi
2 changed files with 12 additions and 0 deletions
|
@ -54,6 +54,17 @@ ErrorOr<Bytes> FixedMemoryStream::read_some(Bytes bytes)
|
|||
return bytes.trim(to_read);
|
||||
}
|
||||
|
||||
ErrorOr<void> FixedMemoryStream::read_until_filled(AK::Bytes bytes)
|
||||
{
|
||||
if (remaining() < bytes.size())
|
||||
return Error::from_string_view_or_print_error_and_return_errno("Can't read past the end of the stream memory"sv, EINVAL);
|
||||
|
||||
m_bytes.slice(m_offset).copy_trimmed_to(bytes);
|
||||
m_offset += bytes.size();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<size_t> FixedMemoryStream::seek(i64 offset, SeekMode seek_mode)
|
||||
{
|
||||
switch (seek_mode) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue