[Poppler-bugs] [Bug 9405] Enhancements to PSTokenizer performance
bugzilla-daemon at annarchy.freedesktop.org
bugzilla-daemon at annarchy.freedesktop.org
Wed Dec 20 14:29:43 PST 2006
Please do not reply to this email: if you want to comment on the bug, go to
the URL shown below and enter yourcomments there.
https://bugs.freedesktop.org/show_bug.cgi?id=9405
------- Additional Comments From scotty1024 at mac.com 2006-12-20 14:29 -------
--- PSTokenizer.cc.~1.1.1.1.~ 2005-03-03 11:46:03.000000000 -0800
+++ PSTokenizer.cc 2006-12-20 08:32:02.000000000 -0800
@@ -55,7 +55,7 @@
int c;
int i;
- // skip whitespace and comments
+ // skip leading whitespace and comments
comment = gFalse;
while (1) {
if ((c = getChar()) == EOF) {
@@ -74,16 +74,20 @@
}
}
+ // Reserve room for terminating '\0'
+ size--;
+
// read a token
i = 0;
buf[i++] = c;
+
if (c == '(') {
backslash = gFalse;
while ((c = lookChar()) != EOF) {
- if (i < size - 1) {
+ consumeChar();
+ if (i < size) {
buf[i++] = c;
}
- getChar();
if (c == '\\') {
backslash = gTrue;
} else if (!backslash && c == ')') {
@@ -94,8 +98,8 @@
}
} else if (c == '<') {
while ((c = lookChar()) != EOF) {
- getChar();
- if (i < size - 1) {
+ consumeChar();
+ if (i < size) {
buf[i++] = c;
}
if (c == '>') {
@@ -104,13 +108,17 @@
}
} else if (c != '[' && c != ']') {
while ((c = lookChar()) != EOF && !specialChars[c]) {
- getChar();
- if (i < size - 1) {
+ consumeChar();
+ if (i < size) {
buf[i++] = c;
}
}
}
+
+ // Zero terminate token string
buf[i] = '\0';
+
+ // Return length of token
*length = i;
return gTrue;
@@ -123,13 +131,18 @@
return charBuf;
}
+void PSTokenizer::consumeChar() {
+ charBuf = -1;
+}
+
int PSTokenizer::getChar() {
- int c;
+ int c = charBuf;
- if (charBuf < 0) {
- charBuf = (*getCharFunc)(data);
- }
- c = charBuf;
+ if (c < 0) {
+ c = (*getCharFunc)(data);
+ } else {
charBuf = -1;
+ }
+
return c;
}
--- PSTokenizer.h.~1.1.1.1.~ 2005-03-03 11:46:01.000000000 -0800
+++ PSTokenizer.h 2006-12-20 08:37:09.000000000 -0800
@@ -29,6 +29,7 @@
private:
int lookChar();
+ void consumeChar();
int getChar();
int (*getCharFunc)(void *);
--
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Poppler-bugs
mailing list