1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:27:42 +00:00

Everywhere: Pass AK::ReadonlyBytes by value

This commit is contained in:
Andreas Kling 2021-11-11 01:06:34 +01:00
parent 8b1108e485
commit 80d4e830a0
42 changed files with 96 additions and 96 deletions

View file

@ -182,14 +182,14 @@ public:
return try_ensure_capacity_slowpath(new_capacity); return try_ensure_capacity_slowpath(new_capacity);
} }
void append(ReadonlyBytes const& bytes) void append(ReadonlyBytes bytes)
{ {
MUST(try_append(bytes)); MUST(try_append(bytes));
} }
void append(void const* data, size_t data_size) { append({ data, data_size }); } void append(void const* data, size_t data_size) { append({ data, data_size }); }
ErrorOr<void> try_append(ReadonlyBytes const& bytes) ErrorOr<void> try_append(ReadonlyBytes bytes)
{ {
return try_append(bytes.data(), bytes.size()); return try_append(bytes.data(), bytes.size());
} }

View file

@ -351,7 +351,7 @@ requires(HasFormatter<T>) struct Formatter<Vector<T>> : StandardFormatter {
template<> template<>
struct Formatter<ReadonlyBytes> : Formatter<StringView> { struct Formatter<ReadonlyBytes> : Formatter<StringView> {
void format(FormatBuilder& builder, ReadonlyBytes const& value) void format(FormatBuilder& builder, ReadonlyBytes value)
{ {
if (m_mode == Mode::Pointer) { if (m_mode == Mode::Pointer) {
Formatter<FlatPtr> formatter { *this }; Formatter<FlatPtr> formatter { *this };

View file

@ -54,7 +54,7 @@ const KernelSymbol* symbolicate_kernel_address(FlatPtr address)
return nullptr; return nullptr;
} }
UNMAP_AFTER_INIT static void load_kernel_symbols_from_data(ReadonlyBytes const& buffer) UNMAP_AFTER_INIT static void load_kernel_symbols_from_data(ReadonlyBytes buffer)
{ {
g_lowest_kernel_symbol_address = 0xffffffff; g_lowest_kernel_symbol_address = 0xffffffff;
g_highest_kernel_symbol_address = 0; g_highest_kernel_symbol_address = 0;

View file

@ -143,7 +143,7 @@ void TarOutputStream::add_directory(const String& path, mode_t mode)
VERIFY(m_stream.write_or_error(Bytes { &padding, block_size - sizeof(header) })); VERIFY(m_stream.write_or_error(Bytes { &padding, block_size - sizeof(header) }));
} }
void TarOutputStream::add_file(const String& path, mode_t mode, const ReadonlyBytes& bytes) void TarOutputStream::add_file(const String& path, mode_t mode, ReadonlyBytes bytes)
{ {
VERIFY(!m_finished); VERIFY(!m_finished);
TarFileHeader header; TarFileHeader header;

View file

@ -53,7 +53,7 @@ private:
class TarOutputStream { class TarOutputStream {
public: public:
TarOutputStream(OutputStream&); TarOutputStream(OutputStream&);
void add_file(const String& path, mode_t, const ReadonlyBytes&); void add_file(const String& path, mode_t, ReadonlyBytes);
void add_directory(const String& path, mode_t); void add_directory(const String& path, mode_t);
void finish(); void finish();

View file

@ -8,7 +8,7 @@
namespace Archive { namespace Archive {
bool Zip::find_end_of_central_directory_offset(const ReadonlyBytes& buffer, size_t& offset) bool Zip::find_end_of_central_directory_offset(ReadonlyBytes buffer, size_t& offset)
{ {
for (size_t backwards_offset = 0; backwards_offset <= UINT16_MAX; backwards_offset++) // the file may have a trailing comment of an arbitrary 16 bit length for (size_t backwards_offset = 0; backwards_offset <= UINT16_MAX; backwards_offset++) // the file may have a trailing comment of an arbitrary 16 bit length
{ {
@ -24,7 +24,7 @@ bool Zip::find_end_of_central_directory_offset(const ReadonlyBytes& buffer, size
return false; return false;
} }
Optional<Zip> Zip::try_create(const ReadonlyBytes& buffer) Optional<Zip> Zip::try_create(ReadonlyBytes buffer)
{ {
size_t end_of_central_directory_offset; size_t end_of_central_directory_offset;
if (!find_end_of_central_directory_offset(buffer, end_of_central_directory_offset)) if (!find_end_of_central_directory_offset(buffer, end_of_central_directory_offset))

View file

@ -207,11 +207,11 @@ struct ZipMember {
class Zip { class Zip {
public: public:
static Optional<Zip> try_create(const ReadonlyBytes& buffer); static Optional<Zip> try_create(ReadonlyBytes buffer);
bool for_each_member(Function<IterationDecision(const ZipMember&)>); bool for_each_member(Function<IterationDecision(const ZipMember&)>);
private: private:
static bool find_end_of_central_directory_offset(const ReadonlyBytes&, size_t& offset); static bool find_end_of_central_directory_offset(ReadonlyBytes, size_t& offset);
u16 member_count { 0 }; u16 member_count { 0 };
size_t members_start_offset { 0 }; size_t members_start_offset { 0 };

View file

@ -1052,7 +1052,7 @@ void DeflateCompressor::final_flush()
flush(); flush();
} }
Optional<ByteBuffer> DeflateCompressor::compress_all(const ReadonlyBytes& bytes, CompressionLevel compression_level) Optional<ByteBuffer> DeflateCompressor::compress_all(ReadonlyBytes bytes, CompressionLevel compression_level)
{ {
DuplexMemoryStream output_stream; DuplexMemoryStream output_stream;
DeflateCompressor deflate_stream { output_stream, compression_level }; DeflateCompressor deflate_stream { output_stream, compression_level };

View file

@ -151,7 +151,7 @@ public:
bool write_or_error(ReadonlyBytes) override; bool write_or_error(ReadonlyBytes) override;
void final_flush(); void final_flush();
static Optional<ByteBuffer> compress_all(const ReadonlyBytes& bytes, CompressionLevel = CompressionLevel::GOOD); static Optional<ByteBuffer> compress_all(ReadonlyBytes bytes, CompressionLevel = CompressionLevel::GOOD);
private: private:
Bytes pending_block() { return { m_rolling_window + block_size, block_size }; } Bytes pending_block() { return { m_rolling_window + block_size, block_size }; }

View file

@ -261,7 +261,7 @@ bool GzipCompressor::write_or_error(ReadonlyBytes bytes)
return true; return true;
} }
Optional<ByteBuffer> GzipCompressor::compress_all(const ReadonlyBytes& bytes) Optional<ByteBuffer> GzipCompressor::compress_all(ReadonlyBytes bytes)
{ {
DuplexMemoryStream output_stream; DuplexMemoryStream output_stream;
GzipCompressor gzip_stream { output_stream }; GzipCompressor gzip_stream { output_stream };

View file

@ -87,7 +87,7 @@ public:
size_t write(ReadonlyBytes) override; size_t write(ReadonlyBytes) override;
bool write_or_error(ReadonlyBytes) override; bool write_or_error(ReadonlyBytes) override;
static Optional<ByteBuffer> compress_all(const ReadonlyBytes& bytes); static Optional<ByteBuffer> compress_all(ReadonlyBytes bytes);
private: private:
OutputStream& m_output_stream; OutputStream& m_output_stream;

View file

@ -41,7 +41,7 @@ Optional<Zlib> Zlib::try_create(ReadonlyBytes data)
return zlib; return zlib;
} }
Zlib::Zlib(const ReadonlyBytes& data) Zlib::Zlib(ReadonlyBytes data)
: m_input_data(data) : m_input_data(data)
{ {
} }

View file

@ -22,7 +22,7 @@ public:
static Optional<ByteBuffer> decompress_all(ReadonlyBytes); static Optional<ByteBuffer> decompress_all(ReadonlyBytes);
private: private:
Zlib(const ReadonlyBytes& data); Zlib(ReadonlyBytes data);
u8 m_compression_method; u8 m_compression_method;
u8 m_compression_info; u8 m_compression_info;

View file

@ -137,7 +137,7 @@ String guess_mime_type_based_on_filename(StringView path)
ENUMERATE_HEADER_CONTENTS ENUMERATE_HEADER_CONTENTS
#undef __ENUMERATE_MIME_TYPE_HEADER #undef __ENUMERATE_MIME_TYPE_HEADER
Optional<String> guess_mime_type_based_on_sniffed_bytes(const ReadonlyBytes& bytes) Optional<String> guess_mime_type_based_on_sniffed_bytes(ReadonlyBytes bytes)
{ {
#define __ENUMERATE_MIME_TYPE_HEADER(var_name, mime_type, pattern_offset, pattern_size, ...) \ #define __ENUMERATE_MIME_TYPE_HEADER(var_name, mime_type, pattern_offset, pattern_size, ...) \
if (static_cast<ssize_t>(bytes.size()) >= pattern_offset && bytes.slice(pattern_offset).starts_with(var_name)) \ if (static_cast<ssize_t>(bytes.size()) >= pattern_offset && bytes.slice(pattern_offset).starts_with(var_name)) \

View file

@ -49,6 +49,6 @@ private:
String guess_mime_type_based_on_filename(StringView); String guess_mime_type_based_on_filename(StringView);
Optional<String> guess_mime_type_based_on_sniffed_bytes(const ReadonlyBytes&); Optional<String> guess_mime_type_based_on_sniffed_bytes(ReadonlyBytes);
} }

View file

@ -59,7 +59,7 @@ Reader::Reader(ReadonlyBytes coredump_bytes)
VERIFY(m_notes_segment_index != -1); VERIFY(m_notes_segment_index != -1);
} }
Optional<ByteBuffer> Reader::decompress_coredump(const ReadonlyBytes& raw_coredump) Optional<ByteBuffer> Reader::decompress_coredump(ReadonlyBytes raw_coredump)
{ {
auto decompressed_coredump = Compress::GzipDecompressor::decompress_all(raw_coredump); auto decompressed_coredump = Compress::GzipDecompressor::decompress_all(raw_coredump);
if (!decompressed_coredump.has_value()) if (!decompressed_coredump.has_value())

View file

@ -55,7 +55,7 @@ private:
explicit Reader(ByteBuffer); explicit Reader(ByteBuffer);
explicit Reader(NonnullRefPtr<MappedFile>); explicit Reader(NonnullRefPtr<MappedFile>);
static Optional<ByteBuffer> decompress_coredump(const ReadonlyBytes&); static Optional<ByteBuffer> decompress_coredump(ReadonlyBytes);
class NotesEntryIterator { class NotesEntryIterator {
public: public:

View file

@ -34,7 +34,7 @@ public:
{ {
} }
explicit GHash(const ReadonlyBytes& key) explicit GHash(ReadonlyBytes key)
{ {
VERIFY(key.size() >= 16); VERIFY(key.size() >= 16);
for (size_t i = 0; i < 16; i += 4) { for (size_t i = 0; i < 16; i += 4) {

View file

@ -64,7 +64,7 @@ public:
encrypt(in, out, ivec); encrypt(in, out, ivec);
} }
void encrypt(const ReadonlyBytes& in, Bytes out, const ReadonlyBytes& iv_in, const ReadonlyBytes& aad, Bytes tag) void encrypt(ReadonlyBytes in, Bytes out, ReadonlyBytes iv_in, ReadonlyBytes aad, Bytes tag)
{ {
auto iv_buf_result = ByteBuffer::copy(iv_in); auto iv_buf_result = ByteBuffer::copy(iv_in);
// Not enough memory to figure out :shrug: // Not enough memory to figure out :shrug:

View file

@ -27,7 +27,7 @@ public:
virtual void update(const u8*, size_t) = 0; virtual void update(const u8*, size_t) = 0;
void update(const Bytes& buffer) { update(buffer.data(), buffer.size()); }; void update(const Bytes& buffer) { update(buffer.data(), buffer.size()); };
void update(const ReadonlyBytes& buffer) { update(buffer.data(), buffer.size()); }; void update(ReadonlyBytes buffer) { update(buffer.data(), buffer.size()); };
void update(const ByteBuffer& buffer) { update(buffer.data(), buffer.size()); }; void update(const ByteBuffer& buffer) { update(buffer.data(), buffer.size()); };
void update(StringView string) { update((const u8*)string.characters_without_null_termination(), string.length()); }; void update(StringView string) { update((const u8*)string.characters_without_null_termination(), string.length()); };

View file

@ -111,7 +111,7 @@ RefPtr<Gfx::Bitmap> Clipboard::bitmap() const
return bitmap; return bitmap;
} }
void Clipboard::set_data(ReadonlyBytes const& data, String const& type, HashMap<String, String> const& metadata) void Clipboard::set_data(ReadonlyBytes data, String const& type, HashMap<String, String> const& metadata)
{ {
auto buffer_or_error = Core::AnonymousBuffer::create_with_size(data.size()); auto buffer_or_error = Core::AnonymousBuffer::create_with_size(data.size());
if (buffer_or_error.is_error()) { if (buffer_or_error.is_error()) {

View file

@ -42,7 +42,7 @@ public:
String mime_type() const { return data_and_type().mime_type; } String mime_type() const { return data_and_type().mime_type; }
RefPtr<Gfx::Bitmap> bitmap() const; RefPtr<Gfx::Bitmap> bitmap() const;
void set_data(ReadonlyBytes const& data, String const& mime_type = "text/plain", HashMap<String, String> const& metadata = {}); void set_data(ReadonlyBytes data, String const& mime_type = "text/plain", HashMap<String, String> const& metadata = {});
void set_plain_text(String const& text) { set_data(text.bytes()); } void set_plain_text(String const& text) { set_data(text.bytes()); }
void set_bitmap(Gfx::Bitmap const&); void set_bitmap(Gfx::Bitmap const&);
void clear(); void clear();

View file

@ -143,7 +143,7 @@ u32 Cmap::glyph_id_for_code_point(u32 code_point) const
return subtable.glyph_id_for_code_point(code_point); return subtable.glyph_id_for_code_point(code_point);
} }
Optional<Cmap> Cmap::from_slice(ReadonlyBytes const& slice) Optional<Cmap> Cmap::from_slice(ReadonlyBytes slice)
{ {
if (slice.size() < (size_t)Sizes::TableHeader) { if (slice.size() < (size_t)Sizes::TableHeader) {
return {}; return {};

View file

@ -37,7 +37,7 @@ public:
UnicodeFullRepertoire = 10, UnicodeFullRepertoire = 10,
}; };
Subtable(ReadonlyBytes const& slice, u16 platform_id, u16 encoding_id) Subtable(ReadonlyBytes slice, u16 platform_id, u16 encoding_id)
: m_slice(slice) : m_slice(slice)
, m_raw_platform_id(platform_id) , m_raw_platform_id(platform_id)
, m_encoding_id(encoding_id) , m_encoding_id(encoding_id)
@ -81,7 +81,7 @@ public:
u16 m_encoding_id { 0 }; u16 m_encoding_id { 0 };
}; };
static Optional<Cmap> from_slice(ReadonlyBytes const&); static Optional<Cmap> from_slice(ReadonlyBytes);
u32 num_subtables() const; u32 num_subtables() const;
Optional<Subtable> subtable(u32 index) const; Optional<Subtable> subtable(u32 index) const;
void set_active_index(u32 index) { m_active_index = index; } void set_active_index(u32 index) { m_active_index = index; }
@ -99,7 +99,7 @@ private:
EncodingRecord = 8, EncodingRecord = 8,
}; };
Cmap(ReadonlyBytes const& slice) Cmap(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }

View file

@ -52,7 +52,7 @@ u32 tag_from_str(char const* str)
return be_u32((u8 const*)str); return be_u32((u8 const*)str);
} }
Optional<Head> Head::from_slice(ReadonlyBytes const& slice) Optional<Head> Head::from_slice(ReadonlyBytes slice)
{ {
if (slice.size() < (size_t)Sizes::Table) { if (slice.size() < (size_t)Sizes::Table) {
return {}; return {};
@ -108,7 +108,7 @@ IndexToLocFormat Head::index_to_loc_format() const
} }
} }
Optional<Hhea> Hhea::from_slice(ReadonlyBytes const& slice) Optional<Hhea> Hhea::from_slice(ReadonlyBytes slice)
{ {
if (slice.size() < (size_t)Sizes::Table) { if (slice.size() < (size_t)Sizes::Table) {
return {}; return {};
@ -141,7 +141,7 @@ u16 Hhea::number_of_h_metrics() const
return be_u16(m_slice.offset_pointer((u32)Offsets::NumberOfHMetrics)); return be_u16(m_slice.offset_pointer((u32)Offsets::NumberOfHMetrics));
} }
Optional<Maxp> Maxp::from_slice(ReadonlyBytes const& slice) Optional<Maxp> Maxp::from_slice(ReadonlyBytes slice)
{ {
if (slice.size() < (size_t)Sizes::TableV0p5) { if (slice.size() < (size_t)Sizes::TableV0p5) {
return {}; return {};
@ -154,7 +154,7 @@ u16 Maxp::num_glyphs() const
return be_u16(m_slice.offset_pointer((u32)Offsets::NumGlyphs)); return be_u16(m_slice.offset_pointer((u32)Offsets::NumGlyphs));
} }
Optional<Hmtx> Hmtx::from_slice(ReadonlyBytes const& slice, u32 num_glyphs, u32 number_of_h_metrics) Optional<Hmtx> Hmtx::from_slice(ReadonlyBytes slice, u32 num_glyphs, u32 number_of_h_metrics)
{ {
if (slice.size() < number_of_h_metrics * (u32)Sizes::LongHorMetric + (num_glyphs - number_of_h_metrics) * (u32)Sizes::LeftSideBearing) { if (slice.size() < number_of_h_metrics * (u32)Sizes::LongHorMetric + (num_glyphs - number_of_h_metrics) * (u32)Sizes::LeftSideBearing) {
return {}; return {};
@ -162,7 +162,7 @@ Optional<Hmtx> Hmtx::from_slice(ReadonlyBytes const& slice, u32 num_glyphs, u32
return Hmtx(slice, num_glyphs, number_of_h_metrics); return Hmtx(slice, num_glyphs, number_of_h_metrics);
} }
Optional<Name> Name::from_slice(ReadonlyBytes const& slice) Optional<Name> Name::from_slice(ReadonlyBytes slice)
{ {
return Name(slice); return Name(slice);
} }

View file

@ -56,7 +56,7 @@ public:
Gfx::FloatPoint point; Gfx::FloatPoint point;
}; };
PointIterator(ReadonlyBytes const& slice, u16 num_points, u32 flags_offset, u32 x_offset, u32 y_offset, Gfx::AffineTransform affine) PointIterator(ReadonlyBytes slice, u16 num_points, u32 flags_offset, u32 x_offset, u32 y_offset, Gfx::AffineTransform affine)
: m_slice(slice) : m_slice(slice)
, m_points_remaining(num_points) , m_points_remaining(num_points)
, m_flags_offset(flags_offset) , m_flags_offset(flags_offset)
@ -322,7 +322,7 @@ void Rasterizer::draw_line(Gfx::FloatPoint p0, Gfx::FloatPoint p1)
} }
} }
Optional<Loca> Loca::from_slice(ReadonlyBytes const& slice, u32 num_glyphs, IndexToLocFormat index_to_loc_format) Optional<Loca> Loca::from_slice(ReadonlyBytes slice, u32 num_glyphs, IndexToLocFormat index_to_loc_format)
{ {
switch (index_to_loc_format) { switch (index_to_loc_format) {
case IndexToLocFormat::Offset16: case IndexToLocFormat::Offset16:
@ -352,7 +352,7 @@ u32 Loca::get_glyph_offset(u32 glyph_id) const
} }
} }
static void get_ttglyph_offsets(ReadonlyBytes const& slice, u32 num_points, u32 flags_offset, u32* x_offset, u32* y_offset) static void get_ttglyph_offsets(ReadonlyBytes slice, u32 num_points, u32 flags_offset, u32* x_offset, u32* y_offset)
{ {
u32 flags_size = 0; u32 flags_size = 0;
u32 x_size = 0; u32 x_size = 0;

View file

@ -30,11 +30,11 @@ private:
class Loca { class Loca {
public: public:
static Optional<Loca> from_slice(ReadonlyBytes const&, u32 num_glyphs, IndexToLocFormat); static Optional<Loca> from_slice(ReadonlyBytes, u32 num_glyphs, IndexToLocFormat);
u32 get_glyph_offset(u32 glyph_id) const; u32 get_glyph_offset(u32 glyph_id) const;
private: private:
Loca(ReadonlyBytes const& slice, u32 num_glyphs, IndexToLocFormat index_to_loc_format) Loca(ReadonlyBytes slice, u32 num_glyphs, IndexToLocFormat index_to_loc_format)
: m_slice(slice) : m_slice(slice)
, m_num_glyphs(num_glyphs) , m_num_glyphs(num_glyphs)
, m_index_to_loc_format(index_to_loc_format) , m_index_to_loc_format(index_to_loc_format)
@ -50,7 +50,7 @@ class Glyf {
public: public:
class Glyph { class Glyph {
public: public:
Glyph(ReadonlyBytes const& slice, i16 xmin, i16 ymin, i16 xmax, i16 ymax, i16 num_contours = -1) Glyph(ReadonlyBytes slice, i16 xmin, i16 ymin, i16 xmax, i16 ymax, i16 num_contours = -1)
: m_xmin(xmin) : m_xmin(xmin)
, m_ymin(ymin) , m_ymin(ymin)
, m_xmax(xmax) , m_xmax(xmax)
@ -89,7 +89,7 @@ public:
Gfx::AffineTransform affine; Gfx::AffineTransform affine;
}; };
ComponentIterator(ReadonlyBytes const& slice) ComponentIterator(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }
@ -133,7 +133,7 @@ public:
ReadonlyBytes m_slice; ReadonlyBytes m_slice;
}; };
Glyf(ReadonlyBytes const& slice) Glyf(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }

View file

@ -18,7 +18,7 @@ enum class IndexToLocFormat {
class Head { class Head {
public: public:
static Optional<Head> from_slice(ReadonlyBytes const&); static Optional<Head> from_slice(ReadonlyBytes);
u16 units_per_em() const; u16 units_per_em() const;
i16 xmin() const; i16 xmin() const;
i16 ymin() const; i16 ymin() const;
@ -43,7 +43,7 @@ private:
Table = 54, Table = 54,
}; };
Head(ReadonlyBytes const& slice) Head(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }
@ -53,7 +53,7 @@ private:
class Hhea { class Hhea {
public: public:
static Optional<Hhea> from_slice(ReadonlyBytes const&); static Optional<Hhea> from_slice(ReadonlyBytes);
i16 ascender() const; i16 ascender() const;
i16 descender() const; i16 descender() const;
i16 line_gap() const; i16 line_gap() const;
@ -72,7 +72,7 @@ private:
Table = 36, Table = 36,
}; };
Hhea(ReadonlyBytes const& slice) Hhea(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }
@ -82,7 +82,7 @@ private:
class Maxp { class Maxp {
public: public:
static Optional<Maxp> from_slice(ReadonlyBytes const&); static Optional<Maxp> from_slice(ReadonlyBytes);
u16 num_glyphs() const; u16 num_glyphs() const;
private: private:
@ -93,7 +93,7 @@ private:
TableV0p5 = 6, TableV0p5 = 6,
}; };
Maxp(ReadonlyBytes const& slice) Maxp(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }
@ -108,7 +108,7 @@ struct GlyphHorizontalMetrics {
class Hmtx { class Hmtx {
public: public:
static Optional<Hmtx> from_slice(ReadonlyBytes const&, u32 num_glyphs, u32 number_of_h_metrics); static Optional<Hmtx> from_slice(ReadonlyBytes, u32 num_glyphs, u32 number_of_h_metrics);
GlyphHorizontalMetrics get_glyph_horizontal_metrics(u32 glyph_id) const; GlyphHorizontalMetrics get_glyph_horizontal_metrics(u32 glyph_id) const;
private: private:
@ -117,7 +117,7 @@ private:
LeftSideBearing = 2 LeftSideBearing = 2
}; };
Hmtx(ReadonlyBytes const& slice, u32 num_glyphs, u32 number_of_h_metrics) Hmtx(ReadonlyBytes slice, u32 num_glyphs, u32 number_of_h_metrics)
: m_slice(slice) : m_slice(slice)
, m_num_glyphs(num_glyphs) , m_num_glyphs(num_glyphs)
, m_number_of_h_metrics(number_of_h_metrics) , m_number_of_h_metrics(number_of_h_metrics)
@ -143,7 +143,7 @@ public:
i16 typographic_descender() const; i16 typographic_descender() const;
i16 typographic_line_gap() const; i16 typographic_line_gap() const;
explicit OS2(ReadonlyBytes const& slice) explicit OS2(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }
@ -165,7 +165,7 @@ public:
enum class WindowsLanguage { enum class WindowsLanguage {
EnglishUnitedStates = 0x0409, EnglishUnitedStates = 0x0409,
}; };
static Optional<Name> from_slice(ReadonlyBytes const&); static Optional<Name> from_slice(ReadonlyBytes);
String family_name() const { return string_for_id(NameId::FamilyName); } String family_name() const { return string_for_id(NameId::FamilyName); }
String subfamily_name() const { return string_for_id(NameId::SubfamilyName); } String subfamily_name() const { return string_for_id(NameId::SubfamilyName); }
@ -189,7 +189,7 @@ private:
TypographicSubfamilyName = 17, TypographicSubfamilyName = 17,
}; };
Name(ReadonlyBytes const& slice) Name(ReadonlyBytes slice)
: m_slice(slice) : m_slice(slice)
{ {
} }

View file

@ -20,7 +20,7 @@ void Client::die()
on_death(); on_death();
} }
Optional<DecodedImage> Client::decode_image(const ReadonlyBytes& encoded_data) Optional<DecodedImage> Client::decode_image(ReadonlyBytes encoded_data)
{ {
if (encoded_data.is_empty()) if (encoded_data.is_empty())
return {}; return {};

View file

@ -30,7 +30,7 @@ class Client final
C_OBJECT(Client); C_OBJECT(Client);
public: public:
Optional<DecodedImage> decode_image(const ReadonlyBytes&); Optional<DecodedImage> decode_image(ReadonlyBytes);
Function<void()> on_death; Function<void()> on_death;

View file

@ -34,7 +34,7 @@ String OutlineItem::to_string(int indent) const
return builder.to_string(); return builder.to_string();
} }
RefPtr<Document> Document::create(ReadonlyBytes const& bytes) RefPtr<Document> Document::create(ReadonlyBytes bytes)
{ {
auto parser = adopt_ref(*new Parser({}, bytes)); auto parser = adopt_ref(*new Parser({}, bytes));
auto document = adopt_ref(*new Document(parser)); auto document = adopt_ref(*new Document(parser));

View file

@ -72,7 +72,7 @@ struct OutlineDict final : public RefCounted<OutlineDict> {
class Document final : public RefCounted<Document> { class Document final : public RefCounted<Document> {
public: public:
static RefPtr<Document> create(ReadonlyBytes const& bytes); static RefPtr<Document> create(ReadonlyBytes bytes);
ALWAYS_INLINE RefPtr<OutlineDict> const& outline() const { return m_outline; } ALWAYS_INLINE RefPtr<OutlineDict> const& outline() const { return m_outline; }

View file

@ -11,7 +11,7 @@
namespace PDF { namespace PDF {
Optional<ByteBuffer> Filter::decode(ReadonlyBytes const& bytes, FlyString const& encoding_type) Optional<ByteBuffer> Filter::decode(ReadonlyBytes bytes, FlyString const& encoding_type)
{ {
if (encoding_type == CommonNames::ASCIIHexDecode) if (encoding_type == CommonNames::ASCIIHexDecode)
return decode_ascii_hex(bytes); return decode_ascii_hex(bytes);
@ -37,7 +37,7 @@ Optional<ByteBuffer> Filter::decode(ReadonlyBytes const& bytes, FlyString const&
return {}; return {};
} }
Optional<ByteBuffer> Filter::decode_ascii_hex(ReadonlyBytes const& bytes) Optional<ByteBuffer> Filter::decode_ascii_hex(ReadonlyBytes bytes)
{ {
if (bytes.size() % 2 == 0) if (bytes.size() % 2 == 0)
return decode_hex(bytes); return decode_hex(bytes);
@ -68,7 +68,7 @@ Optional<ByteBuffer> Filter::decode_ascii_hex(ReadonlyBytes const& bytes)
return { move(output) }; return { move(output) };
}; };
Optional<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes const& bytes) Optional<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes bytes)
{ {
Vector<u8> buff; Vector<u8> buff;
buff.ensure_capacity(bytes.size()); buff.ensure_capacity(bytes.size());
@ -123,13 +123,13 @@ Optional<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes const& bytes)
return ByteBuffer::copy(buff.span()); return ByteBuffer::copy(buff.span());
}; };
Optional<ByteBuffer> Filter::decode_lzw(ReadonlyBytes const&) Optional<ByteBuffer> Filter::decode_lzw(ReadonlyBytes)
{ {
dbgln("LZW decoding is not supported"); dbgln("LZW decoding is not supported");
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
}; };
Optional<ByteBuffer> Filter::decode_flate(ReadonlyBytes const& bytes) Optional<ByteBuffer> Filter::decode_flate(ReadonlyBytes bytes)
{ {
// FIXME: The spec says Flate decoding is "based on" zlib, does that mean they // FIXME: The spec says Flate decoding is "based on" zlib, does that mean they
// aren't exactly the same? // aren't exactly the same?
@ -139,37 +139,37 @@ Optional<ByteBuffer> Filter::decode_flate(ReadonlyBytes const& bytes)
return buff.value(); return buff.value();
}; };
Optional<ByteBuffer> Filter::decode_run_length(ReadonlyBytes const&) Optional<ByteBuffer> Filter::decode_run_length(ReadonlyBytes)
{ {
// FIXME: Support RunLength decoding // FIXME: Support RunLength decoding
TODO(); TODO();
}; };
Optional<ByteBuffer> Filter::decode_ccitt(ReadonlyBytes const&) Optional<ByteBuffer> Filter::decode_ccitt(ReadonlyBytes)
{ {
// FIXME: Support CCITT decoding // FIXME: Support CCITT decoding
TODO(); TODO();
}; };
Optional<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes const&) Optional<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes)
{ {
// FIXME: Support JBIG2 decoding // FIXME: Support JBIG2 decoding
TODO(); TODO();
}; };
Optional<ByteBuffer> Filter::decode_dct(ReadonlyBytes const&) Optional<ByteBuffer> Filter::decode_dct(ReadonlyBytes)
{ {
// FIXME: Support dct decoding // FIXME: Support dct decoding
TODO(); TODO();
}; };
Optional<ByteBuffer> Filter::decode_jpx(ReadonlyBytes const&) Optional<ByteBuffer> Filter::decode_jpx(ReadonlyBytes)
{ {
// FIXME: Support JPX decoding // FIXME: Support JPX decoding
TODO(); TODO();
}; };
Optional<ByteBuffer> Filter::decode_crypt(ReadonlyBytes const&) Optional<ByteBuffer> Filter::decode_crypt(ReadonlyBytes)
{ {
// FIXME: Support Crypt decoding // FIXME: Support Crypt decoding
TODO(); TODO();

View file

@ -13,19 +13,19 @@ namespace PDF {
class Filter { class Filter {
public: public:
static Optional<ByteBuffer> decode(ReadonlyBytes const& bytes, FlyString const& encoding_type); static Optional<ByteBuffer> decode(ReadonlyBytes bytes, FlyString const& encoding_type);
private: private:
static Optional<ByteBuffer> decode_ascii_hex(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_ascii_hex(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_ascii85(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_ascii85(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_lzw(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_lzw(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_flate(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_flate(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_run_length(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_run_length(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_ccitt(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_ccitt(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_jbig2(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_jbig2(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_dct(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_dct(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_jpx(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_jpx(ReadonlyBytes bytes);
static Optional<ByteBuffer> decode_crypt(ReadonlyBytes const& bytes); static Optional<ByteBuffer> decode_crypt(ReadonlyBytes bytes);
}; };
} }

View file

@ -157,7 +157,7 @@ private:
class PlainTextStreamObject final : public StreamObject { class PlainTextStreamObject final : public StreamObject {
public: public:
PlainTextStreamObject(NonnullRefPtr<DictObject> const& dict, ReadonlyBytes const& bytes) PlainTextStreamObject(NonnullRefPtr<DictObject> const& dict, ReadonlyBytes bytes)
: StreamObject(dict) : StreamObject(dict)
, m_bytes(bytes) , m_bytes(bytes)
{ {

View file

@ -23,18 +23,18 @@ static NonnullRefPtr<T> make_object(Args... args) requires(IsBaseOf<Object, T>)
return adopt_ref(*new T(forward<Args>(args)...)); return adopt_ref(*new T(forward<Args>(args)...));
} }
Vector<Command> Parser::parse_graphics_commands(ReadonlyBytes const& bytes) Vector<Command> Parser::parse_graphics_commands(ReadonlyBytes bytes)
{ {
auto parser = adopt_ref(*new Parser(bytes)); auto parser = adopt_ref(*new Parser(bytes));
return parser->parse_graphics_commands(); return parser->parse_graphics_commands();
} }
Parser::Parser(Badge<Document>, ReadonlyBytes const& bytes) Parser::Parser(Badge<Document>, ReadonlyBytes bytes)
: m_reader(bytes) : m_reader(bytes)
{ {
} }
Parser::Parser(ReadonlyBytes const& bytes) Parser::Parser(ReadonlyBytes bytes)
: m_reader(bytes) : m_reader(bytes)
{ {
} }
@ -408,7 +408,7 @@ RefPtr<DictObject> Parser::parse_file_trailer()
return dict; return dict;
} }
Optional<Parser::PageOffsetHintTable> Parser::parse_page_offset_hint_table(ReadonlyBytes const& hint_stream_bytes) Optional<Parser::PageOffsetHintTable> Parser::parse_page_offset_hint_table(ReadonlyBytes hint_stream_bytes)
{ {
if (hint_stream_bytes.size() < sizeof(PageOffsetHintTable)) if (hint_stream_bytes.size() < sizeof(PageOffsetHintTable))
return {}; return {};
@ -456,7 +456,7 @@ Optional<Parser::PageOffsetHintTable> Parser::parse_page_offset_hint_table(Reado
return hint_table; return hint_table;
} }
Optional<Vector<Parser::PageOffsetHintTableEntry>> Parser::parse_all_page_offset_hint_table_entries(PageOffsetHintTable const& hint_table, ReadonlyBytes const& hint_stream_bytes) Optional<Vector<Parser::PageOffsetHintTableEntry>> Parser::parse_all_page_offset_hint_table_entries(PageOffsetHintTable const& hint_table, ReadonlyBytes hint_stream_bytes)
{ {
InputMemoryStream input_stream(hint_stream_bytes); InputMemoryStream input_stream(hint_stream_bytes);
input_stream.seek(sizeof(PageOffsetHintTable)); input_stream.seek(sizeof(PageOffsetHintTable));

View file

@ -24,9 +24,9 @@ public:
Linearized, Linearized,
}; };
static Vector<Command> parse_graphics_commands(ReadonlyBytes const&); static Vector<Command> parse_graphics_commands(ReadonlyBytes);
Parser(Badge<Document>, ReadonlyBytes const&); Parser(Badge<Document>, ReadonlyBytes);
[[nodiscard]] ALWAYS_INLINE RefPtr<DictObject> const& trailer() const { return m_trailer; } [[nodiscard]] ALWAYS_INLINE RefPtr<DictObject> const& trailer() const { return m_trailer; }
void set_document(RefPtr<Document> const&); void set_document(RefPtr<Document> const&);
@ -86,15 +86,15 @@ private:
friend struct AK::Formatter<PageOffsetHintTable>; friend struct AK::Formatter<PageOffsetHintTable>;
friend struct AK::Formatter<PageOffsetHintTableEntry>; friend struct AK::Formatter<PageOffsetHintTableEntry>;
explicit Parser(ReadonlyBytes const&); explicit Parser(ReadonlyBytes);
bool parse_header(); bool parse_header();
LinearizationResult initialize_linearization_dict(); LinearizationResult initialize_linearization_dict();
bool initialize_linearized_xref_table(); bool initialize_linearized_xref_table();
bool initialize_non_linearized_xref_table(); bool initialize_non_linearized_xref_table();
bool initialize_hint_tables(); bool initialize_hint_tables();
Optional<PageOffsetHintTable> parse_page_offset_hint_table(ReadonlyBytes const& hint_stream_bytes); Optional<PageOffsetHintTable> parse_page_offset_hint_table(ReadonlyBytes hint_stream_bytes);
Optional<Vector<PageOffsetHintTableEntry>> parse_all_page_offset_hint_table_entries(PageOffsetHintTable const&, ReadonlyBytes const& hint_stream_bytes); Optional<Vector<PageOffsetHintTableEntry>> parse_all_page_offset_hint_table_entries(PageOffsetHintTable const&, ReadonlyBytes hint_stream_bytes);
RefPtr<XRefTable> parse_xref_table(); RefPtr<XRefTable> parse_xref_table();
RefPtr<DictObject> parse_file_trailer(); RefPtr<DictObject> parse_file_trailer();

View file

@ -16,12 +16,12 @@ namespace PDF {
class Reader { class Reader {
public: public:
explicit Reader(ReadonlyBytes const& bytes) explicit Reader(ReadonlyBytes bytes)
: m_bytes(bytes) : m_bytes(bytes)
{ {
} }
ALWAYS_INLINE ReadonlyBytes const& bytes() const { return m_bytes; } ALWAYS_INLINE ReadonlyBytes bytes() const { return m_bytes; }
ALWAYS_INLINE size_t offset() const { return m_offset; } ALWAYS_INLINE size_t offset() const { return m_offset; }
bool done() const bool done() const

View file

@ -273,7 +273,7 @@ void TLSv12::ensure_hmac(size_t digest_size, bool local)
m_hmac_remote = move(hmac); m_hmac_remote = move(hmac);
} }
ByteBuffer TLSv12::hmac_message(const ReadonlyBytes& buf, const Optional<ReadonlyBytes> buf2, size_t mac_length, bool local) ByteBuffer TLSv12::hmac_message(ReadonlyBytes buf, const Optional<ReadonlyBytes> buf2, size_t mac_length, bool local)
{ {
u64 sequence_number = AK::convert_between_host_and_network_endian(local ? m_context.local_sequence_number : m_context.remote_sequence_number); u64 sequence_number = AK::convert_between_host_and_network_endian(local ? m_context.local_sequence_number : m_context.remote_sequence_number);
ensure_hmac(mac_length, local); ensure_hmac(mac_length, local);

View file

@ -395,7 +395,7 @@ private:
void consume(ReadonlyBytes record); void consume(ReadonlyBytes record);
ByteBuffer hmac_message(const ReadonlyBytes& buf, const Optional<ReadonlyBytes> buf2, size_t mac_length, bool local = false); ByteBuffer hmac_message(ReadonlyBytes buf, const Optional<ReadonlyBytes> buf2, size_t mac_length, bool local = false);
void ensure_hmac(size_t digest_size, bool local); void ensure_hmac(size_t digest_size, bool local);
void update_packet(ByteBuffer& packet); void update_packet(ByteBuffer& packet);

View file

@ -1248,7 +1248,7 @@ void TerminalWidget::set_font_and_resize_to_fit(const Gfx::Font& font)
// Used for sending data that was not directly typed by the user. // Used for sending data that was not directly typed by the user.
// This basically wraps the code that handles sending the escape sequence in bracketed paste mode. // This basically wraps the code that handles sending the escape sequence in bracketed paste mode.
void TerminalWidget::send_non_user_input(const ReadonlyBytes& bytes) void TerminalWidget::send_non_user_input(ReadonlyBytes bytes)
{ {
constexpr StringView leading_control_sequence = "\e[200~"; constexpr StringView leading_control_sequence = "\e[200~";
constexpr StringView trailing_control_sequence = "\e[201~"; constexpr StringView trailing_control_sequence = "\e[201~";

View file

@ -128,7 +128,7 @@ private:
void set_logical_focus(bool); void set_logical_focus(bool);
void send_non_user_input(const ReadonlyBytes&); void send_non_user_input(ReadonlyBytes);
Gfx::IntRect glyph_rect(u16 row, u16 column); Gfx::IntRect glyph_rect(u16 row, u16 column);
Gfx::IntRect row_rect(u16 row); Gfx::IntRect row_rect(u16 row);