From 49212c0d8dc8db6657735036028948bf3ab9ede0 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 30 Aug 2019 07:59:29 -0600 Subject: Use "in" in preference to string find method In places where only the found/not found status is needed, use the membership operator (in) for checks instead - makes for easier reading and is considered faster for shorter strings. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 4 ++++ src/engine/SCons/Environment.py | 4 ++-- src/engine/SCons/Tool/msvs.py | 6 +++--- src/engine/SCons/Tool/swig.py | 2 +- src/test_setup.py | 9 ++++----- test/Configure/option--config.py | 2 +- test/Java/RMIC.py | 14 +++++++------- test/QT/installed.py | 16 ++++++++-------- test/Repository/RMIC.py | 6 +++--- test/Win32/mingw.py | 16 ++++++++-------- 10 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 6450da5..87f4e28 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -12,6 +12,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER across threads. Results in ~13% improvement for parallel builds (-j# > 1) with many shared nodes. + From Mats Wichmann + - Replace instances of string find method with "in" checks where + the index from find() was not used. + RELEASE 3.1.1 - Mon, 07 Aug 2019 20:09:12 -0500 diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 2e1e742..08104c5 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -790,7 +790,7 @@ class SubstitutionEnvironment(object): elif arg == '-mwindows': dict['LINKFLAGS'].append(arg) elif arg[:5] == '-std=': - if arg[5:].find('++')!=-1: + if '++' in arg[5:]: key='CXXFLAGS' else: key='CFLAGS' @@ -2343,7 +2343,7 @@ class OverrideEnvironment(Base): return attr.clone(self) else: return attr - + def __setattr__(self, name, value): setattr(self.__dict__['__subject'], name, value) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index d27294b..7dca9e1 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -652,7 +652,7 @@ class _GenerateV6DSP(_DSPGenerator): for base in ("BASE ",""): self.file.write('# PROP %sUse_MFC 0\n' '# PROP %sUse_Debug_Libraries ' % (base, base)) - if kind.lower().find('debug') < 0: + if 'debug' not in kind.lower(): self.file.write('0\n') else: self.file.write('1\n') @@ -731,7 +731,7 @@ class _GenerateV6DSP(_DSPGenerator): line = dspfile.readline() # skip until marker while line: - if line.find("# End Project") > -1: + if "# End Project" in line: break line = dspfile.readline() @@ -1049,7 +1049,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): line = dspfile.readline() # skip until marker while line: - if line.find('