diff options
author | Jack Lloyd <[email protected]> | 2017-12-10 11:02:43 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-10 12:18:58 -0500 |
commit | c03fbef1ada3e1c87edba7ca725ad3592d185b25 (patch) | |
tree | eb2311d544867fd97027ffb96b36e2a55e773ca8 /configure.py | |
parent | 0ef7a671f578e804a2309ce14d1e581b2ca9eca1 (diff) |
A couple of simple optimizations
Weirdly, copy.deepcopy of a set of str is much slower than just
creating a new set - maybe because it is also copying the strings?
But there is no need for that because while we edit the set we don't
edit any members. Saves about 1.5 seconds on Pi2.
Diffstat (limited to 'configure.py')
-rwxr-xr-x | configure.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/configure.py b/configure.py index 3a8dc7645..ccc7bfbf0 100755 --- a/configure.py +++ b/configure.py @@ -20,7 +20,6 @@ On Jython target detection does not work (use --os and --cpu). """ import collections -import copy import json import sys import os @@ -1612,17 +1611,25 @@ def yield_objectfile_list(sources, obj_dir, obj_suffix): def generate_build_info(build_paths, modules, cc, arch, osinfo): # pylint: disable=too-many-locals + # first create a map of src_file->owning module + + module_that_owns = {} + + for mod in modules: + for src in mod.sources(): + module_that_owns[src] = mod + def _isa_specific_flags(src): if os.path.basename(src) == 'test_simd.cpp': return cc.get_isa_specific_flags(['simd'], arch) - for mod in modules: - if src in mod.sources(): - isas = mod.need_isa - if 'simd' in mod.dependencies(): - isas.append('simd') + if src in module_that_owns: + module = module_that_owns[src] + isas = module.need_isa + if 'simd' in module.dependencies(): + isas.append('simd') - return cc.get_isa_specific_flags(isas, arch) + return cc.get_isa_specific_flags(isas, arch) if src.startswith('botan_all_'): isas = src.replace('botan_all_', '').replace('.cpp', '').split('_') @@ -2073,7 +2080,7 @@ class ModulesChooser(object): if loaded_modules is None: loaded_modules = set([]) else: - loaded_modules = copy.deepcopy(loaded_modules) + loaded_modules = set(loaded_modules) if module not in available_modules: return False, None @@ -2379,7 +2386,7 @@ class AmalgamationGenerator(object): @staticmethod def strip_header_goop(header_name, header_lines): - lines = copy.deepcopy(header_lines) # defensive copy: don't mutate argument + lines = header_lines start_header_guard_index = None for index, line in enumerate(lines): |