LibPDF: Use make_object<>() to make objects

No behavior change.
This commit is contained in:
Nico Weber 2023-12-18 21:31:27 -05:00 committed by Andreas Kling
parent 9e1df152d9
commit 13641693cb
Notes: sideshowbarker 2024-07-17 07:16:27 +09:00
2 changed files with 4 additions and 4 deletions

View File

@ -113,7 +113,7 @@ static PDF::Value make_array(Vector<float> floats)
Vector<PDF::Value> values;
for (auto f : floats)
values.append(PDF::Value { f });
return PDF::Value { adopt_ref(*new PDF::ArrayObject(move(values))) };
return PDF::Value { make_object<PDF::ArrayObject>(move(values)) };
}
static PDF::PDFErrorOr<NonnullRefPtr<PDF::Function>> make_function(int type, ReadonlyBytes data, Vector<float> domain, Vector<float> range, Function<void(HashMap<DeprecatedFlyString, PDF::Value>&)> extra_keys = nullptr)
@ -124,8 +124,8 @@ static PDF::PDFErrorOr<NonnullRefPtr<PDF::Function>> make_function(int type, Rea
map.set(PDF::CommonNames::Range, make_array(move(range)));
if (extra_keys)
extra_keys(map);
auto dict = adopt_ref(*new PDF::DictObject(move(map)));
auto stream = adopt_ref(*new PDF::StreamObject(dict, MUST(ByteBuffer::copy(data))));
auto dict = make_object<PDF::DictObject>(move(map));
auto stream = make_object<PDF::StreamObject>(dict, MUST(ByteBuffer::copy(data)));
// document isn't used for anything, but UBSan complains about a (harmless) method call on a null object without it.
auto file = MUST(Core::MappedFile::map("linearized.pdf"sv));

View File

@ -235,7 +235,7 @@ PDFErrorOr<Page> Document::get_page(u32 index)
if (maybe_resources_object.has_value())
resources = maybe_resources_object.value()->cast<DictObject>();
else
resources = adopt_ref(*new DictObject({}));
resources = make_object<DictObject>(HashMap<DeprecatedFlyString, Value> {});
RefPtr<Object> contents;
if (raw_page_object->contains(CommonNames::Contents))