[poppler] poppler/Object.h poppler/Parser.cc poppler/PDFDoc.cc qt5/tests utils/pdfunite.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 19 15:20:23 UTC 2019


 poppler/Object.h               |    2 --
 poppler/PDFDoc.cc              |    5 ++++-
 poppler/Parser.cc              |    5 ++++-
 qt5/tests/check_optcontent.cpp |    4 ++--
 utils/pdfunite.cc              |    8 ++++----
 5 files changed, 14 insertions(+), 10 deletions(-)

New commits:
commit b0a3356f675e76cf26e6e1ac626a32f7b081da8d
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Feb 17 00:54:23 2019 +0100

    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

diff --git a/poppler/Object.h b/poppler/Object.h
index 69d45a1f..edc96f5b 100644
--- a/poppler/Object.h
+++ b/poppler/Object.h
@@ -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;
 
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 822fe613..5cbeeb53 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -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) {
diff --git a/poppler/Parser.cc b/poppler/Parser.cc
index 8caeba91..3090189b 100644
--- a/poppler/Parser.cc
+++ b/poppler/Parser.cc
@@ -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);
     }
diff --git a/qt5/tests/check_optcontent.cpp b/qt5/tests/check_optcontent.cpp
index f883b353..eb5282ee 100644
--- a/qt5/tests/check_optcontent.cpp
+++ b/qt5/tests/check_optcontent.cpp
@@ -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 );
diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc
index 61613f60..73f416e3 100644
--- a/utils/pdfunite.cc
+++ b/utils/pdfunite.cc
@@ -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 } ));
     }
   }
 }


More information about the poppler mailing list