[poppler] poppler/Function.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Sun Jun 7 09:38:56 PDT 2009
poppler/Function.cc | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
New commits:
commit 831288c13c3a7502bbccd1313c6e376283be367c
Author: Albert Astals Cid <aacid at kde.org>
Date: Sun Jun 7 18:37:20 2009 +0200
Optimize roll() a bit
If the number of times to roll is > than half the number of items
rotate in the reverse direction
Makes it be 33% of exec() instead of 42%
diff --git a/poppler/Function.cc b/poppler/Function.cc
index f81f0fd..9c53cec 100644
--- a/poppler/Function.cc
+++ b/poppler/Function.cc
@@ -1001,12 +1001,21 @@ void PSStack::roll(int n, int j) {
if (n <= 0 || j == 0) {
return;
}
- for (i = 0; i < j; ++i) {
- obj = stack[sp];
- for (k = sp; k < sp + n - 1; ++k) {
- stack[k] = stack[k+1];
+ if (j <= n / 2) {
+ for (i = 0; i < j; ++i) {
+ obj = stack[sp];
+ for (k = sp; k < sp + n - 1; ++k) {
+ stack[k] = stack[k+1];
+ }
+ stack[sp + n - 1] = obj;
+ }
+ } else {
+ j = n - j;
+ obj = stack[sp + n - 1];
+ for (k = sp + n - 1; k > sp; --k) {
+ stack[k] = stack[k-1];
}
- stack[sp + n - 1] = obj;
+ stack[sp] = obj;
}
}
More information about the poppler
mailing list