Commit f846c9a2 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

JBIG2Stream: Move Object instead of copying it

parent 09952b05
...@@ -1174,7 +1174,7 @@ JBIG2CodeTable::~JBIG2CodeTable() { ...@@ -1174,7 +1174,7 @@ JBIG2CodeTable::~JBIG2CodeTable() {
// JBIG2Stream // JBIG2Stream
//------------------------------------------------------------------------ //------------------------------------------------------------------------
JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA, Object *globalsStreamRefA): JBIG2Stream::JBIG2Stream(Stream *strA, Object &&globalsStreamA, Object *globalsStreamRefA):
FilterStream(strA) FilterStream(strA)
{ {
pageBitmap = nullptr; pageBitmap = nullptr;
...@@ -1199,8 +1199,8 @@ JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA, Object *globalsSt ...@@ -1199,8 +1199,8 @@ JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA, Object *globalsSt
huffDecoder = new JBIG2HuffmanDecoder(); huffDecoder = new JBIG2HuffmanDecoder();
mmrDecoder = new JBIG2MMRDecoder(); mmrDecoder = new JBIG2MMRDecoder();
if (globalsStreamA->isStream()) { if (globalsStreamA.isStream()) {
globalsStream = globalsStreamA->copy(); globalsStream = std::move(globalsStreamA);
if (globalsStreamRefA->isRef()) if (globalsStreamRefA->isRef())
globalsStreamRef = globalsStreamRefA->getRef(); globalsStreamRef = globalsStreamRefA->getRef();
} }
......
...@@ -43,7 +43,7 @@ class JBIG2MMRDecoder; ...@@ -43,7 +43,7 @@ class JBIG2MMRDecoder;
class JBIG2Stream: public FilterStream { class JBIG2Stream: public FilterStream {
public: public:
JBIG2Stream(Stream *strA, Object *globalsStreamA, Object *globalsStreamRefA); JBIG2Stream(Stream *strA, Object &&globalsStreamA, Object *globalsStreamRefA);
~JBIG2Stream(); ~JBIG2Stream();
StreamKind getKind() override { return strJBIG2; } StreamKind getKind() override { return strJBIG2; }
void reset() override; void reset() override;
......
...@@ -213,7 +213,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re ...@@ -213,7 +213,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re
int encoding; int encoding;
bool endOfLine, byteAlign, endOfBlock, black, damagedRowsBeforeError; bool endOfLine, byteAlign, endOfBlock, black, damagedRowsBeforeError;
int columns, rows; int columns, rows;
Object globals, obj; Object obj;
if (!strcmp(name, "ASCIIHexDecode") || !strcmp(name, "AHx")) { if (!strcmp(name, "ASCIIHexDecode") || !strcmp(name, "AHx")) {
str = new ASCIIHexStream(str); str = new ASCIIHexStream(str);
...@@ -325,12 +325,13 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re ...@@ -325,12 +325,13 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re
} }
str = new FlateStream(str, pred, columns, colors, bits); str = new FlateStream(str, pred, columns, colors, bits);
} else if (!strcmp(name, "JBIG2Decode")) { } else if (!strcmp(name, "JBIG2Decode")) {
Object globals;
if (params->isDict()) { if (params->isDict()) {
XRef *xref = params->getDict()->getXRef(); XRef *xref = params->getDict()->getXRef();
obj = params->dictLookupNF("JBIG2Globals"); obj = params->dictLookupNF("JBIG2Globals");
globals = obj.fetch(xref, recursion); globals = obj.fetch(xref, recursion);
} }
str = new JBIG2Stream(str, &globals, &obj); str = new JBIG2Stream(str, std::move(globals), &obj);
} else if (!strcmp(name, "JPXDecode")) { } else if (!strcmp(name, "JPXDecode")) {
#ifdef HAVE_JPX_DECODER #ifdef HAVE_JPX_DECODER
str = new JPXStream(str); str = new JPXStream(str);
......
Supports Markdown
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