mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
AK: Skip vcalls to Stream::read_value and read_until_filled in LEB128
...for the first byte. This function only really needs to read a single byte at that point, so read_until_filled() is useless and read_value<u8> is functionally equivalent to just a read. This showed up hot in a wasm parse benchmark.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
931b554f68
commit
2cd4b4e28d
Notes:
github-actions[bot]
2025-08-08 10:56:32 +00:00
Author: https://github.com/alimpfard Commit: https://github.com/LadybirdBrowser/ladybird/commit/2cd4b4e28d1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5060 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/R-Goc Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/gmta
13
AK/LEB128.h
13
AK/LEB128.h
@@ -28,7 +28,18 @@ public:
|
|||||||
requires(Unsigned<ValueType>)
|
requires(Unsigned<ValueType>)
|
||||||
{
|
{
|
||||||
// First byte is unrolled for speed
|
// First byte is unrolled for speed
|
||||||
auto byte = TRY(stream.read_value<u8>());
|
u8 byte;
|
||||||
|
do {
|
||||||
|
auto result = stream.read_some({ &byte, 1 });
|
||||||
|
if (result.is_error() && result.error().is_errno() && (result.error().code() == EAGAIN || result.error().code() == EINTR))
|
||||||
|
continue;
|
||||||
|
if (result.is_error())
|
||||||
|
return result.release_error();
|
||||||
|
if (result.value().size() != 1)
|
||||||
|
return Error::from_string_literal("EOF reached before expected end");
|
||||||
|
break;
|
||||||
|
} while (true);
|
||||||
|
|
||||||
if ((byte & 0x80) == 0)
|
if ((byte & 0x80) == 0)
|
||||||
return LEB128<ValueType> { byte };
|
return LEB128<ValueType> { byte };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user