aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/s_expression.h
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2011-07-15 02:27:49 -0700
committerKenneth Graunke <[email protected]>2011-07-20 10:42:43 -0700
commit3875526926123259521514de9c8d675e3797275a (patch)
tree2919b6469aafb47cc70a1c16989deeb0dbaf8fa1 /src/glsl/s_expression.h
parent8d044047f133ad4e4c4f1f6b4a4a1c4a9fa477f5 (diff)
glsl: Avoid massive ralloc_strndup overhead in S-Expression parsing.
When parsing S-Expressions, we need to store nul-terminated strings for Symbol nodes. Prior to this patch, we called ralloc_strndup each time we constructed a new s_symbol. It turns out that this is obscenely expensive. Instead, copy the whole buffer before parsing and overwrite it to contain \0 bytes at the appropriate locations. Since atoms are separated by whitespace, (), or ;, we can safely overwrite the character after a Symbol. While much of the buffer may be unused, copying the whole buffer is simple and guaranteed to provide enough space. Prior to this, running piglit-run.py -t glsl tests/quick.tests with GLSL 1.30 enabled took just over 10 minutes on my machine. Now it takes 5. NOTE: This is a candidate for stable release branches (because it will make running comparison tests so much less irritating.) Signed-off-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/s_expression.h')
-rw-r--r--src/glsl/s_expression.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h
index c9dc676b319..642af19b439 100644
--- a/src/glsl/s_expression.h
+++ b/src/glsl/s_expression.h
@@ -129,7 +129,7 @@ public:
void print();
private:
- char *str;
+ const char *str;
};
/* Lists of expressions: (expr1 ... exprN) */