1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

LibTTF: Use ReadonlyBytes where possible to avoid copies

This commit is contained in:
Stephan Unverwerth 2020-12-29 16:48:30 +01:00 committed by Andreas Kling
parent 187acd8f21
commit 0f6cf9caa1
6 changed files with 48 additions and 48 deletions

View file

@ -90,7 +90,7 @@ Optional<Cmap::Subtable> Cmap::subtable(u32 index) const
u16 encoding_id = be_u16(m_slice.offset_pointer(record_offset + (u32)Offsets::EncodingRecord_EncodingID));
u32 subtable_offset = be_u32(m_slice.offset_pointer(record_offset + (u32)Offsets::EncodingRecord_Offset));
ASSERT(subtable_offset < m_slice.size());
auto subtable_slice = ByteBuffer::copy(m_slice.offset_pointer(subtable_offset), m_slice.size() - subtable_offset);
auto subtable_slice = ReadonlyBytes(m_slice.offset_pointer(subtable_offset), m_slice.size() - subtable_offset);
return Subtable(subtable_slice, platform_id, encoding_id);
}
@ -163,7 +163,7 @@ u32 Cmap::glyph_id_for_codepoint(u32 codepoint) const
return subtable.glyph_id_for_codepoint(codepoint);
}
Optional<Cmap> Cmap::from_slice(const ByteBuffer& slice)
Optional<Cmap> Cmap::from_slice(const ReadonlyBytes& slice)
{
if (slice.size() < (size_t)Sizes::TableHeader) {
return {};