summaryrefslogtreecommitdiff
path: root/src/parse/parse.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-08-01 19:00:59 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-08-01 19:00:59 +0000
commit4680b309e825db1d669b04056bc3cbdf273f5d80 (patch)
treeaee536560cde136c79aa57d043ab0a4e2294d509 /src/parse/parse.c
parent36ca9c1c76f92dd863a1f22ac9f66c07e775d45d (diff)
downloadlibcss-4680b309e825db1d669b04056bc3cbdf273f5d80.tar.gz
libcss-4680b309e825db1d669b04056bc3cbdf273f5d80.tar.bz2
Only intern strings when we get a token from the lexer. Strings in tokens that have been pushed back have already been interned, so it's stupid to re-intern every time. This has required that the lexer permits its clients to modify the data members of the css_token object. That's fine, as it assumes nothing about them (they're basically just a window onto the internal lexer state, anyway).
svn path=/trunk/libcss/; revision=4857
Diffstat (limited to 'src/parse/parse.c')
-rw-r--r--src/parse/parse.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/parse/parse.c b/src/parse/parse.c
index e19bd15..b66642b 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -521,7 +521,6 @@ css_error expect(css_parser *parser, css_token_type type)
*/
css_error getToken(css_parser *parser, const css_token **token)
{
- css_token temp;
parserutils_error perror;
css_error error;
@@ -531,28 +530,31 @@ css_error getToken(css_parser *parser, const css_token **token)
parser->pushback = NULL;
} else {
/* Otherwise, ask the lexer */
- error = css_lexer_get_token(parser->lexer, token);
+ css_token *t;
+
+ error = css_lexer_get_token(parser->lexer, &t);
if (error != CSS_OK)
return error;
- }
- temp = *(*token);
+ if (t->data.ptr != NULL && t->data.len > 0) {
+ /* Insert token text into the dictionary */
+ const parserutils_dict_entry *interned;
- if (temp.data.ptr != NULL && temp.data.len > 0) {
- /* Insert token text into the dictionary */
- const parserutils_dict_entry *interned;
+ perror = parserutils_dict_insert(parser->dictionary,
+ t->data.ptr, t->data.len, &interned);
+ if (perror != PARSERUTILS_OK)
+ return css_error_from_parserutils_error(perror);
- perror = parserutils_dict_insert(parser->dictionary,
- temp.data.ptr, temp.data.len, &interned);
- if (perror != PARSERUTILS_OK)
- return css_error_from_parserutils_error(perror);
+ t->data.ptr = interned->data;
+ t->data.len = interned->len;
+ }
- temp.data.ptr = interned->data;
- temp.data.len = interned->len;
+ *token = t;
}
/* Append token to vector */
- perror = parserutils_vector_append(parser->tokens, &temp);
+ perror = parserutils_vector_append(parser->tokens,
+ (css_token *) (*token));
if (perror != PARSERUTILS_OK)
return css_error_from_parserutils_error(perror);