1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 05:54:58 +00:00

LibPDF: Use a struct for the subsection in parse_xref_stream

This commit is contained in:
Hendiadyoin1 2024-02-29 16:33:13 +01:00 committed by Andrew Kaster
parent 3e3b34ab8a
commit 773a280bdf

View file

@ -8,7 +8,6 @@
#include <AK/BitStream.h>
#include <AK/Endian.h>
#include <AK/MemoryStream.h>
#include <AK/Tuple.h>
#include <LibPDF/CommonNames.h>
#include <LibPDF/Document.h>
#include <LibPDF/DocumentParser.h>
@ -425,7 +424,12 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_stream()
auto number_of_object_entries = dict->get_value("Size").get<int>();
Vector<Tuple<int, int>> subsections;
struct Subsection {
int start;
int count;
};
Vector<Subsection> subsections;
if (dict->contains(CommonNames::Index)) {
auto index_array = TRY(dict->get_array(m_document, CommonNames::Index));
if (index_array->size() % 2 != 0)
@ -449,9 +453,7 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_stream()
size_t byte_index = 0;
for (auto const& subsection : subsections) {
auto start = subsection.get<0>();
auto count = subsection.get<1>();
for (auto [start, count] : subsections) {
Vector<XRefEntry> entries;
for (int i = 0; i < count; i++) {