This will make it possible to remove unnecessary strlen and strncmp
calls.
---
 src/compiler/glsl/glcpp/glcpp-parse.y | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y 
b/src/compiler/glsl/glcpp/glcpp-parse.y
index fe211a0f0b..8cdd4c9d5b 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -450,10 +450,12 @@ control_line_error:
 
 integer_constant:
        INTEGER_STRING {
-               if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) {
-                       $$ = strtoll ($1 + 2, NULL, 16);
-               } else if ($1[0] == '0') {
-                       $$ = strtoll ($1, NULL, 8);
+               if ($1[0] == '0') {
+                       if ($1[1] == 'x' && $1[2] != '\0') {
+                               $$ = strtoll ($1 + 2, NULL, 16);
+                       } else {
+                               $$ = strtoll ($1, NULL, 8);
+                       }
                } else {
                        $$ = strtoll ($1, NULL, 10);
                }
-- 
2.11.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to