summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glcpp/glcpp-parse.y
diff options
context:
space:
mode:
authorVladislav Egorov <[email protected]>2017-05-21 22:49:15 +0200
committerTimothy Arceri <[email protected]>2017-05-22 12:34:28 +1000
commitb8e792ee25e01ce1e9e4f3ed444f8e1ade8c992e (patch)
tree1d11443708054eee9b0793a668055ea435aef25a /src/compiler/glsl/glcpp/glcpp-parse.y
parent1575a8146a33bfddb2e498ce77fa0ca8f0f0c85e (diff)
glcpp: Avoid unnecessary strcmp()
strcmp() is slow. Initiate comparison with "__LINE__" or "__FILE__" only if the identifier starts with '_', which is rare. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glcpp/glcpp-parse.y')
-rw-r--r--src/compiler/glsl/glcpp/glcpp-parse.y14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
index 5cb2a380605..fe211a0f0bd 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -1829,11 +1829,15 @@ _glcpp_parser_expand_node(glcpp_parser_t *parser, token_node_t *node,
/* Special handling for __LINE__ and __FILE__, (not through
* the hash table). */
- if (strcmp(identifier, "__LINE__") == 0)
- return _token_list_create_with_one_integer(parser, node->token->location.first_line);
-
- if (strcmp(identifier, "__FILE__") == 0)
- return _token_list_create_with_one_integer(parser, node->token->location.source);
+ if (*identifier == '_') {
+ if (strcmp(identifier, "__LINE__") == 0)
+ return _token_list_create_with_one_integer(parser,
+ node->token->location.first_line);
+
+ if (strcmp(identifier, "__FILE__") == 0)
+ return _token_list_create_with_one_integer(parser,
+ node->token->location.source);
+ }
/* Look up this identifier in the hash table. */
entry = _mesa_hash_table_search(parser->defines, identifier);