mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
LibPDF: Avoid an unnecessary copy in Filter::decode_ascii85()
This commit is contained in:
parent
e80d3ff518
commit
dac703a0b8
1 changed files with 6 additions and 6 deletions
|
@ -93,8 +93,8 @@ PDFErrorOr<ByteBuffer> Filter::decode_ascii_hex(ReadonlyBytes bytes)
|
||||||
|
|
||||||
PDFErrorOr<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes bytes)
|
PDFErrorOr<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes bytes)
|
||||||
{
|
{
|
||||||
Vector<u8> buff;
|
ByteBuffer buffer;
|
||||||
buff.ensure_capacity(bytes.size());
|
TRY(buffer.try_ensure_capacity(bytes.size()));
|
||||||
|
|
||||||
size_t byte_index = 0;
|
size_t byte_index = 0;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ PDFErrorOr<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes bytes)
|
||||||
if (bytes[byte_index] == 'z') {
|
if (bytes[byte_index] == 'z') {
|
||||||
byte_index++;
|
byte_index++;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
buff.append(0);
|
buffer.append(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ PDFErrorOr<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < to_write - 1; i++)
|
for (size_t i = 0; i < to_write - 1; i++)
|
||||||
buff.append(reinterpret_cast<u8*>(&number)[3 - i]);
|
buffer.append(reinterpret_cast<u8*>(&number)[3 - i]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,10 +140,10 @@ PDFErrorOr<ByteBuffer> Filter::decode_ascii85(ReadonlyBytes bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
buff.append(reinterpret_cast<u8*>(&number)[3 - i]);
|
buffer.append(reinterpret_cast<u8*>(&number)[3 - i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRY(ByteBuffer::copy(buff.span()));
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFErrorOr<ByteBuffer> Filter::decode_png_prediction(Bytes bytes, int bytes_per_row)
|
PDFErrorOr<ByteBuffer> Filter::decode_png_prediction(Bytes bytes, int bytes_per_row)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue