summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2009-01-27 00:26:08 +0100
committerAlbert Astals Cid <aacid@kde.org>2009-01-27 00:26:08 +0100
commitb1d4efb082ac3dadd7752a557e5aeb6651e17471 (patch)
tree0cc90a7d0f80d70a8aeb64d99308592d1e9dabd3
parent90f95127d8d89cfcadeb7d701437ab07ce4a8a61 (diff)
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
-rw-r--r--poppler/Function.cc12
-rw-r--r--poppler/Function.h15
2 files changed, 23 insertions, 4 deletions
diff --git a/poppler/Function.cc b/poppler/Function.cc
index 282cee24..41591408 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@kde.org>
+// Copyright (C) 2006, 2008, 2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006 Jeff Muizelaar <jeff@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 d16873d7..4cf6fd0e 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@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;
};