Commit 8ee4f32c authored by Adam Reichold's avatar Adam Reichold

Align signature of Array::copy with Dict::copy as a preparation for implicit sharing

parent 3955fe7f
......@@ -46,14 +46,14 @@ Array::Array(XRef *xrefA) {
Array::~Array() {
}
Object Array::copy(XRef *xrefA) const {
Array *Array::copy(XRef *xrefA) const {
arrayLocker();
Array *a = new Array(xrefA);
a->elems.reserve(elems.size());
for (const auto& elem : elems) {
a->elems.push_back(elem.copy());
}
return Object(a);
return a;
}
void Array::add(Object &&elem) {
......
......@@ -57,7 +57,7 @@ public:
int getLength() const { return elems.size(); }
// Copy array with new xref
Object copy(XRef *xrefA) const;
Array *copy(XRef *xrefA) const;
// Add an element
// elem becomes a dead object after this call
......
......@@ -337,21 +337,19 @@ Dict *Page::getResourceDictCopy(XRef *xrefA) {
}
void Page::replaceXRef(XRef *xrefA) {
Object obj1;
Dict *pageDict = pageObj.getDict()->copy(xrefA);
xref = xrefA;
trans = pageDict->lookupNF("Trans").copy();
annotsObj = pageDict->lookupNF("Annots").copy();
contents = pageDict->lookupNF("Contents").copy();
if (contents.isArray()) {
obj1 = pageDict->lookupNF("Contents").copy();
contents = obj1.getArray()->copy(xrefA);
contents = Object(contents.getArray()->copy(xrefA));
}
thumb = pageDict->lookupNF("Thumb").copy();
actions = pageDict->lookupNF("AA").copy();
obj1 = pageDict->lookup("Resources");
if (obj1.isDict()) {
attrs->replaceResource(std::move(obj1));
Object resources = pageDict->lookup("Resources");
if (resources.isDict()) {
attrs->replaceResource(std::move(resources));
}
delete pageDict;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment