1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

LibPDF: Get rid of PlainText/Encoded StreamObject

This was a small optimization to allow a stream object to simply hold
a reference to the bytes in a PDF document rather than duplicating
them. However, as we move into features such as encryption, this
optimization does more harm than good. This can be revisited in the
future if necessary.
This commit is contained in:
Matthew Olsson 2022-03-20 11:07:47 -07:00 committed by Andreas Kling
parent 15b7999313
commit c98bda8ce6
3 changed files with 6 additions and 40 deletions

View file

@ -997,10 +997,10 @@ PDFErrorOr<NonnullRefPtr<StreamObject>> Parser::parse_stream(NonnullRefPtr<DictO
warnln("Failed to decode filter: {}", maybe_bytes.error().string_literal());
return error(String::formatted("Failed to decode filter {}", maybe_bytes.error().string_literal()));
}
return make_object<EncodedStreamObject>(dict, move(maybe_bytes.value()));
return make_object<StreamObject>(dict, maybe_bytes.value());
}
return make_object<PlainTextStreamObject>(dict, bytes);
return make_object<StreamObject>(dict, MUST(ByteBuffer::copy(bytes)));
}
PDFErrorOr<Vector<Command>> Parser::parse_graphics_commands()