mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Rename the const
overload of FixedMemoryStream::bytes()
Due to overload resolutions rules, this simple code provokes a crash: ReadonlyBytes readonly_bytes{}; FixedMemoryStream stream{readonly_bytes}; ReadonlyBytes give_them_back{stream.bytes()}; // -> Panics on VERIFY(m_writing_enabled); // but this is fine: auto bytes = static_cast<FixedMemoryStream const&>(*stream).bytes() If we need to be explicit about it, let's rename the overload instead of adding that `static_cast`.
This commit is contained in:
parent
66c9696687
commit
18b7ddd0b5
Notes:
sideshowbarker
2024-07-17 05:09:48 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/18b7ddd0b5 Pull-request: https://github.com/SerenityOS/serenity/pull/20135 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/supercomputer7
3 changed files with 3 additions and 3 deletions
|
@ -114,7 +114,7 @@ Bytes FixedMemoryStream::bytes()
|
|||
VERIFY(m_writing_enabled);
|
||||
return m_bytes;
|
||||
}
|
||||
ReadonlyBytes FixedMemoryStream::bytes() const
|
||||
ReadonlyBytes FixedMemoryStream::readonly_bytes() const
|
||||
{
|
||||
return m_bytes;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
virtual ErrorOr<void> write_until_depleted(ReadonlyBytes bytes) override;
|
||||
|
||||
Bytes bytes();
|
||||
ReadonlyBytes bytes() const;
|
||||
ReadonlyBytes readonly_bytes() const;
|
||||
size_t offset() const;
|
||||
size_t remaining() const;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
DecoderErrorOr<BooleanDecoder> create_range_decoder(size_t size)
|
||||
{
|
||||
ReadonlyBytes stream_data = static_cast<FixedMemoryStream const&>(*stream).bytes();
|
||||
ReadonlyBytes stream_data = stream->readonly_bytes();
|
||||
auto compressed_header_data = ReadonlyBytes(stream_data.data() + stream->offset(), size);
|
||||
|
||||
// 9.2.1: The Boolean decoding process specified in section 9.2.2 is invoked to read a marker syntax element from the
|
||||
|
|
Loading…
Reference in a new issue