[poppler] poppler/Link.cc poppler/Link.h

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Apr 16 20:28:43 UTC 2018


 poppler/Link.cc |   22 +++++++++++-----------
 poppler/Link.h  |    5 +++--
 2 files changed, 14 insertions(+), 13 deletions(-)

New commits:
commit 444d9d8de5d4f8d627084405e1583b6d6d3900c7
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Apr 16 22:28:18 2018 +0200

    Simplify LinkAction::parseAction a bit
    
    After the discussion on the mailing list, also using unique_ptr was
    wrong

diff --git a/poppler/Link.cc b/poppler/Link.cc
index 42bdaf1b..9ebf33ef 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -70,8 +70,14 @@ LinkAction *LinkAction::parseDest(const Object *obj) {
   return action;
 }
 
+LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI)
+{
+    std::set<int> seenNextActions;
+    return parseAction(obj, baseURI, &seenNextActions);
+}
+
 LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
-                                    std::unique_ptr<std::set<int>> seenNextActions) {
+                                    std::set<int> *seenNextActions) {
   LinkAction *action;
 
   if (!obj->isDict()) {
@@ -160,19 +166,16 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
     // Prevent circles in the tree by checking the ref against used refs in
     // our current tree branch.
     const Object nextRefObj = obj->dictLookupNF("Next");
-    if (!seenNextActions)
-        seenNextActions.reset(new std::set<int>);
     if (nextRefObj.isRef()) {
         const Ref ref = nextRefObj.getRef();
-        if (seenNextActions->find(ref.num) != seenNextActions->end()) {
+        if (!seenNextActions->insert(ref.num).second) {
             error(errSyntaxWarning, -1, "parseAction: Circular next actions detected.");
             return action;
         }
-        seenNextActions->insert(ref.num);
     }
 
     actionList = new GooList(1);
-    actionList->append(parseAction(&nextObj, nullptr, std::move(seenNextActions)));
+    actionList->append(parseAction(&nextObj, nullptr, seenNextActions));
   } else if (nextObj.isArray()) {
     const Array *a = nextObj.getArray();
     const int n = a->getLength();
@@ -185,19 +188,16 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
       }
 
       // Similar circle check as above.
-      if (!seenNextActions)
-        seenNextActions.reset(new std::set<int>);
       const Object obj3Ref = a->getNF(i);
       if (obj3Ref.isRef()) {
           const Ref ref = obj3Ref.getRef();
-          if (seenNextActions->find(ref.num) != seenNextActions->end()) {
+          if (!seenNextActions->insert(ref.num).second) {
               error(errSyntaxWarning, -1, "parseAction: Circular next actions detected in array.");
               return action;
           }
-          seenNextActions->insert(ref.num);
       }
 
-      actionList->append(parseAction(&obj3, nullptr, std::move(seenNextActions)));
+      actionList->append(parseAction(&obj3, nullptr, seenNextActions));
     }
   }
 
diff --git a/poppler/Link.h b/poppler/Link.h
index 77d224d9..4388523c 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -85,8 +85,9 @@ public:
   static LinkAction *parseDest(const Object *obj);
 
   // Parse an action dictionary.
-  static LinkAction *parseAction(const Object *obj, const GooString *baseURI = nullptr,
-                                 std::unique_ptr<std::set<int>> seenNextActions = nullptr);
+  static LinkAction *parseAction(const Object *obj, const GooString *baseURI = nullptr);
+  static LinkAction *parseAction(const Object *obj, const GooString *baseURI,
+                                 std::set<int> *seenNextActions);
 
   // A List of the next actions to execute in order.
   // The list contains pointer to LinkAction objects.


More information about the poppler mailing list