Commit b0a3356f authored by Albert Astals Cid's avatar Albert Astals Cid

Remove the "long" Object objRef constructor

Did analyze the assembler generated by the more verbose option in
Parser.cc that is a hot path and the assembler was the same
parent 60b66323
......@@ -174,8 +174,6 @@ public:
{ assert(streamA); type = objStream; stream = streamA; }
explicit Object(const Ref r)
{ type = objRef; ref.num = r.num; ref.gen = r.gen; }
Object(int numA, int genA)
{ type = objRef; ref.num = numA; ref.gen = genA; }
template<typename T> Object(T) = delete;
......
......@@ -1812,7 +1812,10 @@ bool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, unsi
if (obj2.getRef().num == oldPageNum) {
Object obj3 = array->getNF(i);
if (obj3.isRef()) {
dict->set("P", Object(newPageNum, 0));
Ref r;
r.num = newPageNum;
r.gen = 0;
dict->set("P", Object(r));
getXRef()->setModifiedObject(&obj1, obj3.getRef());
}
} else if (obj2.getRef().num == newPageNum) {
......
......@@ -155,7 +155,10 @@ Object Parser::getObj(bool simpleOnly,
return Object();
}
return Object(num, gen);
Ref r;
r.num = num;
r.gen = gen;
return Object(r);
} else {
return Object(num);
}
......
......@@ -175,7 +175,7 @@ void TestOptionalContent::checkVisibilitySetting()
// In this test, both Ref(21,0) and Ref(28,0) start On,
// based on the file settings
Object ref21obj( 21, 0 );
Object ref21obj( { 21, 0 } );
Ref ref21 = ref21obj.getRef();
OptionalContentGroup *ocgA = ocgs->findOcgByRef( ref21 );
QVERIFY( ocgA );
......@@ -183,7 +183,7 @@ void TestOptionalContent::checkVisibilitySetting()
QVERIFY( (ocgA->getName()->cmp("A")) == 0 );
QCOMPARE( ocgA->getState(), OptionalContentGroup::On );
Object ref28obj( 28, 0 );
Object ref28obj( { 28, 0 } );
Ref ref28 = ref28obj.getRef();
OptionalContentGroup *ocgB = ocgs->findOcgByRef( ref28 );
QVERIFY( ocgB );
......
......@@ -56,7 +56,7 @@ static void doMergeNameTree(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldR
if (mkey.isString() && mvalue.isRef()) {
if (mkey.getString()->cmp(key.getString()) < 0) {
newNameArray->add(Object(new GooString(mkey.getString()->c_str())));
newNameArray->add(Object(mvalue.getRef().num + numOffset, mvalue.getRef().gen));
newNameArray->add(Object( { mvalue.getRef().num + numOffset, mvalue.getRef().gen } ));
j += 2;
} else if (mkey.getString()->cmp(key.getString()) == 0) {
j += 2;
......@@ -76,7 +76,7 @@ static void doMergeNameTree(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldR
Object mvalue = mergeNameArray.arrayGetNF(j + 1);
if (mkey.isString() && mvalue.isRef()) {
newNameArray->add(Object(new GooString(mkey.getString()->c_str())));
newNameArray->add(Object(mvalue.getRef().num + numOffset, mvalue.getRef().gen));
newNameArray->add(Object( { mvalue.getRef().num + numOffset, mvalue.getRef().gen } ));
}
j += 2;
}
......@@ -89,7 +89,7 @@ static void doMergeNameTree(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldR
Object value = mergeNameArray.arrayGetNF(i + 1);
if (key.isString() && value.isRef()) {
newNameArray->add(Object(new GooString(key.getString()->c_str())));
newNameArray->add(Object(value.getRef().num + numOffset, value.getRef().gen));
newNameArray->add(Object( { value.getRef().num + numOffset, value.getRef().gen } ));
}
}
srcNameTree->add("Names", Object(newNameArray));
......@@ -118,7 +118,7 @@ static void doMergeFormDict(Dict *srcFormDict, Dict *mergeFormDict, int numOffse
if (srcFields.isArray() && mergeFields.isArray()) {
for (int i = 0; i < mergeFields.arrayGetLength(); i++) {
Object value = mergeFields.arrayGetNF(i);
srcFields.arrayAdd(Object(value.getRef().num + numOffset, value.getRef().gen));
srcFields.arrayAdd(Object( { value.getRef().num + numOffset, value.getRef().gen } ));
}
}
}
......
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