Commit d0ab87c1 authored by Albert Astals Cid's avatar Albert Astals Cid Committed by Albert Astals Cid

Save an incRef/decRef when creating EmbFile

parent 08d4f02c
......@@ -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;
}
......
......@@ -20,7 +20,7 @@
class EmbFile {
public:
EmbFile(const Object *efStream);
EmbFile(Object &&efStream);
~EmbFile();
EmbFile(const EmbFile &) = delete;
......
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