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

JBIG2Stream: Move Object instead of copying it

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