summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-08-30 13:59:29 (GMT)
committerMats Wichmann <mats@linux.com>2019-08-30 14:04:23 (GMT)
commit49212c0d8dc8db6657735036028948bf3ab9ede0 (patch)
tree08f0ea34bbc36d51a8234a72ea5fe65d3f44c68e /src
parent84843df640e34f83ebea25be851204f400a0d9ec (diff)
downloadSCons-49212c0d8dc8db6657735036028948bf3ab9ede0.zip
SCons-49212c0d8dc8db6657735036028948bf3ab9ede0.tar.gz
SCons-49212c0d8dc8db6657735036028948bf3ab9ede0.tar.bz2
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 <mats@linux.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/CHANGES.txt4
-rw-r--r--src/engine/SCons/Environment.py4
-rw-r--r--src/engine/SCons/Tool/msvs.py6
-rw-r--r--src/engine/SCons/Tool/swig.py2
-rw-r--r--src/test_setup.py9
5 files changed, 14 insertions, 11 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('<!-- SCons Data:') > -1:
+ if '<!-- SCons Data:' in line:
break
line = dspfile.readline()
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index 6ed9d82..f139a09 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -80,7 +80,7 @@ def _find_modules(src):
for m in matches:
mnames.append(m[2])
- directors = directors or m[0].find('directors') >= 0
+ directors = directors or 'directors' in m[0]
return mnames, directors
def _add_director_header_targets(target, env):
diff --git a/src/test_setup.py b/src/test_setup.py
index 09865f5..d9fa5b5 100644
--- a/src/test_setup.py
+++ b/src/test_setup.py
@@ -176,7 +176,7 @@ tar_gz = os.path.join(cwd, 'build', 'dist', '%s.tar.gz' % scons_version)
zip = os.path.join(cwd, 'build', 'dist', '%s.zip' % scons_version)
if os.path.isfile(zip):
- try:
+ try:
import zipfile
except ImportError:
pass
@@ -185,9 +185,9 @@ if os.path.isfile(zip):
for name in zf.namelist():
dname = os.path.dirname(name)
- try:
+ try:
os.makedirs(dname)
- except FileExistsError:
+ except FileExistsError:
pass
# if the file exists, then delete it before writing
# to it so that we don't end up trying to write to a symlink:
@@ -325,8 +325,7 @@ test.must_have_installed(test.man_page_paths())
other_prefix = test.workpath('other-prefix')
test.subdir(other_prefix)
test.run(arguments = 'setup.py install --prefix=%s' % other_prefix)
-test.fail_test(test.stderr().find("you'll have to change the search path yourself")
- != -1)
+test.fail_test("you'll have to change the search path yourself" in test.stderr())
# All done.
test.pass_test()