Mesa (master): glcpp: Skip unnecessary line continuations removal
Timothy Arceri
tarceri at kemper.freedesktop.org
Mon May 22 02:34:55 UTC 2017
Module: Mesa
Branch: master
Commit: 4a47247523e678a3a9d3939e8a3c217188b99452
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a47247523e678a3a9d3939e8a3c217188b99452
Author: Vladislav Egorov <vegorov180 at gmail.com>
Date: Sun May 21 22:49:17 2017 +0200
glcpp: Skip unnecessary line continuations removal
Overwhelming majority of shaders don't use line continuations. In my
shader-db only shaders from the Talos Principle and Serious Sam used
them, less than 1% out of all shaders. Optimize for this case, don't
do any copying if no line continuation was found.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
---
src/compiler/glsl/glcpp/pp.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/compiler/glsl/glcpp/pp.c b/src/compiler/glsl/glcpp/pp.c
index c526f37719..96125f2e2f 100644
--- a/src/compiler/glsl/glcpp/pp.c
+++ b/src/compiler/glsl/glcpp/pp.c
@@ -117,6 +117,12 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
char newline_separator[3];
int collapsed_newlines = 0;
+ backslash = strchr(shader, '\\');
+
+ /* No line continuations were found in this shader, our job is done */
+ if (backslash == NULL)
+ return (char *) shader;
+
search_start = shader;
/* Determine what flavor of newlines this shader is using. GLSL
@@ -157,8 +163,6 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
}
while (true) {
- backslash = strchr(search_start, '\\');
-
/* If we have previously collapsed any line-continuations,
* then we want to insert additional newlines at the next
* occurrence of a newline character to avoid changing any
@@ -204,6 +208,8 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
shader = skip_newline (backslash + 1);
search_start = shader;
}
+
+ backslash = strchr(search_start, '\\');
}
ralloc_strcat(&clean, shader);
More information about the mesa-commit
mailing list