[poppler] poppler/Function.cc poppler/Function.h

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Jan 26 15:28:45 PST 2009


 poppler/Function.cc |   12 ++++++++----
 poppler/Function.h  |   15 +++++++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit b1d4efb082ac3dadd7752a557e5aeb6651e17471
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Jan 27 00:26:08 2009 +0100

    PostScriptFunction::transform optimization
    
    Do not create and destroy a PSStack each time
    PostScriptFunction::transform is called gives a 7% speedup on heavy
    PostScriptFunction::transform pdf like nytimes firefox ad

diff --git a/poppler/Function.cc b/poppler/Function.cc
index 282cee2..4159140 100644
--- a/poppler/Function.cc
+++ b/poppler/Function.cc
@@ -13,7 +13,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2006, 2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2008, 2009 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Jeff Muizelaar <jeff at infidigm.net>
 //
 // To see a description of the changes please see the Changelog file that
@@ -862,6 +862,7 @@ class PSStack {
 public:
 
   PSStack() { sp = psStackSize; }
+  void clear() { sp = psStackSize; }
   void pushBool(GBool booln);
   void pushInt(int intg);
   void pushReal(double real);
@@ -1063,6 +1064,8 @@ PostScriptFunction::PostScriptFunction(Object *funcObj, Dict *dict) {
   str->close();
 
   ok = gTrue;
+  
+  stack = new PSStack();
 
  err2:
   str->close();
@@ -1075,18 +1078,20 @@ PostScriptFunction::PostScriptFunction(PostScriptFunction *func) {
   code = (PSObject *)gmallocn(codeSize, sizeof(PSObject));
   memcpy(code, func->code, codeSize * sizeof(PSObject));
   codeString = func->codeString->copy();
+  stack = new PSStack();
+  memcpy(stack, func->stack, sizeof(PSStack));
 }
 
 PostScriptFunction::~PostScriptFunction() {
   gfree(code);
   delete codeString;
+  delete stack;
 }
 
 void PostScriptFunction::transform(double *in, double *out) {
-  PSStack *stack;
   int i;
 
-  stack = new PSStack();
+  stack->clear();
   for (i = 0; i < m; ++i) {
     //~ may need to check for integers here
     stack->pushReal(in[i]);
@@ -1103,7 +1108,6 @@ void PostScriptFunction::transform(double *in, double *out) {
   // if (!stack->empty()) {
   //   error(-1, "Extra values on stack at end of PostScript function");
   // }
-  delete stack;
 }
 
 GBool PostScriptFunction::parseCode(Stream *str, int *codePtr) {
diff --git a/poppler/Function.h b/poppler/Function.h
index d16873d..4cf6fd0 100644
--- a/poppler/Function.h
+++ b/poppler/Function.h
@@ -6,6 +6,20 @@
 //
 //========================================================================
 
+//========================================================================
+//
+// Modified under the Poppler project - http://poppler.freedesktop.org
+//
+// All changes made under the Poppler project to this file are licensed
+// under GPL version 2 or later
+//
+// Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
+//
+// To see a description of the changes please see the Changelog file that
+// came with your tarball or type make ChangeLog if you are building from git
+//
+//========================================================================
+
 #ifndef FUNCTION_H
 #define FUNCTION_H
 
@@ -220,6 +234,7 @@ private:
 
   GooString *codeString;
   PSObject *code;
+  PSStack *stack;
   int codeSize;
   GBool ok;
 };


More information about the poppler mailing list