[poppler] poppler/FileSpec.cc poppler/FileSpec.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 12 22:59:43 UTC 2018


 poppler/FileSpec.cc |   12 +++++-------
 poppler/FileSpec.h  |    2 +-
 2 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit d0ab87c1471349facd91caa65815670b1e3b7bb7
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Nov 12 18:30:56 2018 +0100

    Save an incRef/decRef when creating EmbFile

diff --git a/poppler/FileSpec.cc b/poppler/FileSpec.cc
index ba555f2f..8a8b9e7e 100644
--- a/poppler/FileSpec.cc
+++ b/poppler/FileSpec.cc
@@ -29,7 +29,7 @@
 
 #include "FileSpec.h"
 
-EmbFile::EmbFile(const Object *efStream)
+EmbFile::EmbFile(Object &&efStream)
 {
   m_size = -1;
   m_createDate = nullptr;
@@ -37,11 +37,11 @@ EmbFile::EmbFile(const Object *efStream)
   m_checksum = nullptr;
   m_mimetype = nullptr;
 
-  m_objStr = efStream->copy();
+  m_objStr = std::move(efStream);
 
-  if (efStream->isStream()) {
+  if (m_objStr.isStream()) {
     // dataDict corresponds to Table 3.41 in the PDF1.6 spec.
-    Dict *dataDict = efStream->streamGetDict();
+    Dict *dataDict = m_objStr.streamGetDict();
 
     // subtype is normally the mimetype
     Object subtypeName = dataDict->lookup("Subtype");
@@ -156,10 +156,8 @@ EmbFile *FileSpec::getEmbeddedFile()
   if (embFile)
     return embFile;
 
-  Object obj1;
   XRef *xref = fileSpec.getDict()->getXRef();
-  obj1 = fileStream.fetch(xref);
-  embFile = new EmbFile(&obj1);
+  embFile = new EmbFile(fileStream.fetch(xref));
 
   return embFile;
 }
diff --git a/poppler/FileSpec.h b/poppler/FileSpec.h
index 58c9e481..a4fcc725 100644
--- a/poppler/FileSpec.h
+++ b/poppler/FileSpec.h
@@ -20,7 +20,7 @@
 
 class EmbFile {
 public:
-  EmbFile(const Object *efStream);
+  EmbFile(Object &&efStream);
   ~EmbFile();
 
   EmbFile(const EmbFile &) = delete;


More information about the poppler mailing list