[poppler] 2 commits - goo/GooList.h poppler/GfxState.cc poppler/Link.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 5 11:21:02 UTC 2018


 goo/GooList.h       |    8 ++++----
 poppler/GfxState.cc |    3 ++-
 poppler/Link.cc     |    6 ++++--
 3 files changed, 10 insertions(+), 7 deletions(-)

New commits:
commit a6929b40d94d92f7583d17bf4befae36eae87631
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Fri Oct 5 12:45:00 2018 +0200

    Remove GooList's reserving constructor since it has only three users and it seems to better to be explicit whether we reserve or resize.

diff --git a/goo/GooList.h b/goo/GooList.h
index aa6f8850..faf34ade 100644
--- a/goo/GooList.h
+++ b/goo/GooList.h
@@ -35,9 +35,6 @@ struct GooList : public std::vector<void *> {
   // Create an empty list.
   GooList() = default;
 
-  // Create an empty list with space for <size> elements.
-  explicit GooList(int size) { reserve(size); }
-
   // Movable but not copyable
   GooList(GooList &&other) = default;
   GooList& operator=(GooList &&other) = default;
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index c31cc1ff..9d11fc55 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -2977,7 +2977,8 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
   int i;
   int *mappingA = nullptr;
 
-  GooList *sepsCSA = new GooList(sepsCS->getLength());
+  GooList *sepsCSA = new GooList();
+  sepsCSA->reserve(sepsCS->getLength());
   for (i = 0; i < sepsCS->getLength(); i++) {
     GfxSeparationColorSpace *scs = (GfxSeparationColorSpace *) sepsCS->get(i);
     if (likely(scs != nullptr)) {
diff --git a/poppler/Link.cc b/poppler/Link.cc
index 877e5213..e2e309b2 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -175,12 +175,14 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
         }
     }
 
-    actionList = new GooList(1);
+    actionList = new GooList();
+    actionList->reserve(1);
     actionList->push_back(parseAction(&nextObj, nullptr, seenNextActions));
   } else if (nextObj.isArray()) {
     const Array *a = nextObj.getArray();
     const int n = a->getLength();
-    actionList = new GooList(n);
+    actionList = new GooList();
+    actionList->reserve(n);
     for (int i = 0; i < n; ++i) {
       const Object obj3 = a->get(i);
       if (!obj3.isDict()) {
commit de89d6449cba119fa86908b2771c4c441cb8a503
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Fri Oct 5 12:29:24 2018 +0200

    Do not use non-standard pragma once and do not change semantics of reserving GooList constructor.

diff --git a/goo/GooList.h b/goo/GooList.h
index 52c8ade4..aa6f8850 100644
--- a/goo/GooList.h
+++ b/goo/GooList.h
@@ -20,7 +20,8 @@
 //
 //========================================================================
 
-#pragma once
+#ifndef GOO_LIST_H
+#define GOO_LIST_H
 
 #include <algorithm>
 #include <vector>
@@ -35,7 +36,7 @@ struct GooList : public std::vector<void *> {
   GooList() = default;
 
   // Create an empty list with space for <size> elements.
-  explicit GooList(int size) : std::vector<void *>(size) {}
+  explicit GooList(int size) { reserve(size); }
 
   // Movable but not copyable
   GooList(GooList &&other) = default;
@@ -63,3 +64,5 @@ inline void deleteGooList(GooList* list) {
   }
   delete list;
 }
+
+#endif // GOO_LIST_H


More information about the poppler mailing list