diff options
author | Albert Astals Cid <aacid@kde.org> | 2013-07-29 01:08:06 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2013-07-29 01:12:50 +0200 |
commit | 4637b1581286381c3d1c6963828d9cd8afc5b9e0 (patch) | |
tree | a027630ee4fb3146e4ea3910442061968cb8b1e9 | |
parent | e04287f2682e46831c04e0ef8d60411f521a2572 (diff) |
Make some pdftops conversions *much* faster
For example: http://ev.kde.org/resources/expense_report.pdf
Without this patch it seems "infinite", which this patch it's a few seconds
The change: Instead of just remembering in xobjStack the set of XObjects (and Patterns,
the variable name was 'wrong') we are currently setting up (i.e. the current chain), we
remember all of them.
This has passed the pdf->ps regression test without a single issue
-rw-r--r-- | poppler/PSOutputDev.cc | 42 | ||||
-rw-r--r-- | poppler/PSOutputDev.h | 6 |
2 files changed, 13 insertions, 35 deletions
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 11add87d..4fe5d7b0 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -1075,7 +1075,6 @@ PSOutputDev::PSOutputDev(const char *fileName, PDFDoc *doc, font16Enc = NULL; imgIDs = NULL; formIDs = NULL; - xobjStack = NULL; paperSizes = NULL; embFontList = NULL; customColors = NULL; @@ -1142,7 +1141,6 @@ PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, font16Enc = NULL; imgIDs = NULL; formIDs = NULL; - xobjStack = NULL; paperSizes = NULL; embFontList = NULL; customColors = NULL; @@ -1276,7 +1274,6 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, formIDLen = 0; formIDSize = 0; - xobjStack = new GooList(); numSaves = 0; numTilingPatterns = 0; nextFunc = 0; @@ -1376,9 +1373,6 @@ PSOutputDev::~PSOutputDev() { } gfree(imgIDs); gfree(formIDs); - if (xobjStack) { - delete xobjStack; - } while (customColors) { cc = customColors; customColors = cc->next; @@ -1658,9 +1652,9 @@ void PSOutputDev::writeTrailer() { void PSOutputDev::setupResources(Dict *resDict) { Object xObjDict, xObjRef, xObj, patDict, patRef, pat, resObj; - Ref ref0, ref1; + Ref ref0; GBool skip; - int i, j; + int i; setupFonts(resDict); setupImages(resDict); @@ -1675,15 +1669,10 @@ void PSOutputDev::setupResources(Dict *resDict) { skip = gFalse; if ((xObjDict.dictGetValNF(i, &xObjRef)->isRef())) { ref0 = xObjRef.getRef(); - for (j = 0; j < xobjStack->getLength(); ++j) { - ref1 = *(Ref *)xobjStack->get(j); - if (ref1.num == ref0.num && ref1.gen == ref0.gen) { - skip = gTrue; - break; - } - } - if (!skip) { - xobjStack->append(&ref0); + if (resourceIDs.find(ref0.num) != resourceIDs.end()) { + skip = gTrue; + } else { + resourceIDs.insert(ref0.num); } } if (!skip) { @@ -1700,9 +1689,6 @@ void PSOutputDev::setupResources(Dict *resDict) { xObj.free(); } - if (xObjRef.isRef() && !skip) { - xobjStack->del(xobjStack->getLength() - 1); - } xObjRef.free(); } } @@ -1718,15 +1704,10 @@ void PSOutputDev::setupResources(Dict *resDict) { skip = gFalse; if ((patDict.dictGetValNF(i, &patRef)->isRef())) { ref0 = patRef.getRef(); - for (j = 0; j < xobjStack->getLength(); ++j) { - ref1 = *(Ref *)xobjStack->get(j); - if (ref1.num == ref0.num && ref1.gen == ref0.gen) { - skip = gTrue; - break; - } - } - if (!skip) { - xobjStack->append(&ref0); + if (resourceIDs.find(ref0.num) != resourceIDs.end()) { + skip = gTrue; + } else { + resourceIDs.insert(ref0.num); } } if (!skip) { @@ -1743,9 +1724,6 @@ void PSOutputDev::setupResources(Dict *resDict) { pat.free(); } - if (patRef.isRef() && !skip) { - xobjStack->del(xobjStack->getLength() - 1); - } patRef.free(); } inType3Char = gFalse; diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index f9dc63c2..92b007ea 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008, 2012 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2008, 2012, 2013 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007 Brad Hards <bradh@kde.org> // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> @@ -43,6 +43,7 @@ #include "GfxState.h" #include "GlobalParams.h" #include "OutputDev.h" +#include <set> class GHooash; class PDFDoc; @@ -428,6 +429,7 @@ private: Ref *fontIDs; // list of object IDs of all used fonts int fontIDLen; // number of entries in fontIDs array int fontIDSize; // size of fontIDs array + std::set<int> resourceIDs; // list of object IDs of objects containing Resources we've already set up GooHash *fontNames; // all used font names PST1FontName *t1FontNames; // font names for Type 1/1C fonts int t1FontNameLen; // number of entries in t1FontNames array @@ -444,8 +446,6 @@ private: Ref *formIDs; // list of IDs for predefined forms int formIDLen; // number of entries in formIDs array int formIDSize; // size of formIDs array - GooList *xobjStack; // stack of XObject dicts currently being - // processed int numSaves; // current number of gsaves int numTilingPatterns; // current number of nested tiling patterns int nextFunc; // next unique number to use for a function |