aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-04-22 15:54:16 -0700
committerDylan Baker <dylan@pnwbakers.com>2019-04-25 12:28:51 -0700
commit5678468c2cc1f4639c68a95fb71f8212c846459b (patch)
treeeeedb656ffa320932b052043355e297809b90633 /mesonbuild/modules
parent8e1670cc60cc853c7ddc81dceb65dc93fa45bfa9 (diff)
downloadmeson-5678468c2cc1f4639c68a95fb71f8212c846459b.zip
meson-5678468c2cc1f4639c68a95fb71f8212c846459b.tar.gz
meson-5678468c2cc1f4639c68a95fb71f8212c846459b.tar.bz2
Don't use len() to test for container emptiness
I ran the numbers once before (it's in the meson history) but it's *much* faster to *not* use len for testing if a container is empty or not.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/cmake.py2
-rw-r--r--mesonbuild/modules/qt.py12
-rw-r--r--mesonbuild/modules/rpm.py6
-rw-r--r--mesonbuild/modules/unstable_icestorm.py2
-rw-r--r--mesonbuild/modules/unstable_simd.py2
5 files changed, 12 insertions, 12 deletions
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py
index d98213d..2878134 100644
--- a/mesonbuild/modules/cmake.py
+++ b/mesonbuild/modules/cmake.py
@@ -158,7 +158,7 @@ class CmakeModule(ExtensionModule):
@permittedKwargs({'input', 'name', 'install_dir', 'configuration'})
def configure_package_config_file(self, interpreter, state, args, kwargs):
- if len(args) > 0:
+ if args:
raise mesonlib.MesonException('configure_package_config_file takes only keyword arguments.')
if 'input' not in kwargs:
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index 0b252ac..11289c4 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -129,13 +129,13 @@ class QtBaseModule(ExtensionModule):
self._detect_tools(state.environment, method)
err_msg = "{0} sources specified and couldn't find {1}, " \
"please check your qt{2} installation"
- if len(moc_headers) + len(moc_sources) > 0 and not self.moc.found():
+ if (moc_headers or moc_sources) and not self.moc.found():
raise MesonException(err_msg.format('MOC', 'moc-qt{}'.format(self.qt_version), self.qt_version))
- if len(rcc_files) > 0:
+ if rcc_files:
if not self.rcc.found():
raise MesonException(err_msg.format('RCC', 'rcc-qt{}'.format(self.qt_version), self.qt_version))
# custom output name set? -> one output file, multiple otherwise
- if len(args) > 0:
+ if args:
qrc_deps = []
for i in rcc_files:
qrc_deps += self.parse_qrc(state, i)
@@ -160,7 +160,7 @@ class QtBaseModule(ExtensionModule):
'depend_files': qrc_deps}
res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
sources.append(res_target)
- if len(ui_files) > 0:
+ if ui_files:
if not self.uic.found():
raise MesonException(err_msg.format('UIC', 'uic-qt{}'.format(self.qt_version), self.qt_version))
arguments = uic_extra_arguments + ['-o', '@OUTPUT@', '@INPUT@']
@@ -183,14 +183,14 @@ class QtBaseModule(ExtensionModule):
'either an external dependency (returned by find_library() or '
'dependency()) or an internal dependency (returned by '
'declare_dependency()).'.format(type(dep).__name__))
- if len(moc_headers) > 0:
+ if moc_headers:
arguments = moc_extra_arguments + inc + compile_args + ['@INPUT@', '-o', '@OUTPUT@']
moc_kwargs = {'output': 'moc_@BASENAME@.cpp',
'arguments': arguments}
moc_gen = build.Generator([self.moc], moc_kwargs)
moc_output = moc_gen.process_files('Qt{} moc header'.format(self.qt_version), moc_headers, state)
sources.append(moc_output)
- if len(moc_sources) > 0:
+ if moc_sources:
arguments = moc_extra_arguments + inc + compile_args + ['@INPUT@', '-o', '@OUTPUT@']
moc_kwargs = {'output': '@BASENAME@.moc',
'arguments': arguments}
diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py
index 9774286..7c1cefb 100644
--- a/mesonbuild/modules/rpm.py
+++ b/mesonbuild/modules/rpm.py
@@ -58,7 +58,7 @@ class RPMModule(ExtensionModule):
elif isinstance(target, TypelibTarget) and target.should_install():
files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0])
for header in coredata.headers:
- if len(header.get_install_subdir()) > 0:
+ if header.get_install_subdir():
files_devel.add('%%{_includedir}/%s/' % header.get_install_subdir())
else:
for hdr_src in header.get_sources():
@@ -66,7 +66,7 @@ class RPMModule(ExtensionModule):
for man in coredata.man:
for man_file in man.get_sources():
files.add('%%{_mandir}/man%u/%s.*' % (int(man_file.split('.')[-1]), man_file))
- if len(files_devel) > 0:
+ if files_devel:
devel_subpkg = True
filename = os.path.join(coredata.environment.get_build_dir(),
@@ -122,7 +122,7 @@ class RPMModule(ExtensionModule):
fn.write('\n')
fn.write('%install\n')
fn.write('%meson_install\n')
- if len(to_delete) > 0:
+ if to_delete:
fn.write('rm -vf %s\n' % ' '.join(to_delete))
fn.write('\n')
fn.write('%check\n')
diff --git a/mesonbuild/modules/unstable_icestorm.py b/mesonbuild/modules/unstable_icestorm.py
index 051dc5f..268c394 100644
--- a/mesonbuild/modules/unstable_icestorm.py
+++ b/mesonbuild/modules/unstable_icestorm.py
@@ -36,7 +36,7 @@ class IceStormModule(ExtensionModule):
def project(self, interpreter, state, args, kwargs):
if not self.yosys_bin:
self.detect_binaries(interpreter)
- if not len(args):
+ if not args:
raise mesonlib.MesonException('Project requires at least one argument, which is the project name.')
proj_name = args[0]
arg_sources = args[1:]
diff --git a/mesonbuild/modules/unstable_simd.py b/mesonbuild/modules/unstable_simd.py
index b64242a..18a1099 100644
--- a/mesonbuild/modules/unstable_simd.py
+++ b/mesonbuild/modules/unstable_simd.py
@@ -65,7 +65,7 @@ class SimdModule(ExtensionModule):
if args is None:
mlog.log('Compiler supports %s:' % iset, mlog.red('NO'))
continue
- if len(args) > 0:
+ if args:
if not compiler.has_multi_arguments(args, state.environment):
mlog.log('Compiler supports %s:' % iset, mlog.red('NO'))
continue