util/glsl2spirv: use if `x in str` instead of `str.find`
authorDylan Baker <dylan.c.baker@intel.com>
Tue, 1 Nov 2022 20:28:18 +0000 (13:28 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 10 Nov 2022 21:14:17 +0000 (21:14 +0000)
The latter is only idiomatically used when a start and/or stop position
is required.

Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449>

src/util/glsl2spirv.py

index bf17f71..dee8fc2 100644 (file)
@@ -86,7 +86,7 @@ def create_include_guard(lines: T.List[str], filename: str) -> T.List[str]:
 
     # remove '#pragma once'
     for idx, l in enumerate(lines):
-        if l.find('#pragma once') != -1:
+        if '#pragma once' in l:
             lines.pop(idx)
             break
 
@@ -95,7 +95,7 @@ def create_include_guard(lines: T.List[str], filename: str) -> T.List[str]:
 
 def convert_to_static_variable(lines: T.List[str], varname: str) -> T.List[str]:
     for idx, l in enumerate(lines):
-        if l.find(varname) != -1:
+        if varname in l:
             lines[idx] = "static " + lines[idx]
             return lines
     raise RuntimeError(f'Did not find {varname}, this is unexpected')
@@ -103,7 +103,7 @@ def convert_to_static_variable(lines: T.List[str], varname: str) -> T.List[str]:
 
 def override_version(lines: T.List[str], glsl_version: str) -> T.List[str]:
     for idx, l in enumerate(lines):
-        if l.find('#version ') != -1:
+        if '#version ' in l:
             lines[idx] = "#version {}\n".format(glsl_version)
             return lines
     raise RuntimeError('Did not find #version directive, this is unexpected')