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
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 11add87..4fe5d7b 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1075,7 +1075,6 @@
   font16Enc = NULL;
   imgIDs = NULL;
   formIDs = NULL;
-  xobjStack = NULL;
   paperSizes = NULL;
   embFontList = NULL;
   customColors = NULL;
@@ -1142,7 +1141,6 @@
   font16Enc = NULL;
   imgIDs = NULL;
   formIDs = NULL;
-  xobjStack = NULL;
   paperSizes = NULL;
   embFontList = NULL;
   customColors = NULL;
@@ -1276,7 +1274,6 @@
   formIDLen = 0;
   formIDSize = 0;
 
-  xobjStack = new GooList();
   numSaves = 0;
   numTilingPatterns = 0;
   nextFunc = 0;
@@ -1376,9 +1373,6 @@
   }
   gfree(imgIDs);
   gfree(formIDs);
-  if (xobjStack) {
-    delete xobjStack;
-  }
   while (customColors) {
     cc = customColors;
     customColors = cc->next;
@@ -1658,9 +1652,9 @@
 
 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 @@
       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 @@
 	xObj.free();
       }
 
-      if (xObjRef.isRef() && !skip) {
-	xobjStack->del(xobjStack->getLength() - 1);
-      }
       xObjRef.free();
     }
   }
@@ -1718,15 +1704,10 @@
       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 @@
 	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 f9dc63c..92b007e 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 @@
   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 @@
   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