diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-08-17 15:27:13 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-08-18 08:11:25 +0200 |
commit | fcf9746232efd03970c963e9e5207e1ec8dc99fd (patch) | |
tree | 81af5a845bd61a8e884022cfe73e7c125163db76 | |
parent | 372f420778f8f4b55b207f9a6be2c20e2bd22c38 (diff) | |
download | meson-fcf9746232efd03970c963e9e5207e1ec8dc99fd.zip meson-fcf9746232efd03970c963e9e5207e1ec8dc99fd.tar.gz meson-fcf9746232efd03970c963e9e5207e1ec8dc99fd.tar.bz2 |
build: optimize extract_objects
extract_objects is repeatedly looking up files in self.sources, which is a list.
Convert it to a set beforehand so that the lookup is O(1).
On a QEMU build, the time spent in extract_objects goes from 3.292s to 0.431s.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | mesonbuild/build.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 5e6db73..edd1506 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -774,6 +774,7 @@ class BuildTarget(Target): def extract_objects(self, srclist): obj_src = [] + sources_set = set(self.sources) for src in srclist: if isinstance(src, str): src = File(False, self.subdir, src) @@ -782,7 +783,7 @@ class BuildTarget(Target): else: raise MesonException('Object extraction arguments must be strings or Files.') # FIXME: It could be a generated source - if src not in self.sources: + if src not in sources_set: raise MesonException('Tried to extract unknown source {}.'.format(src)) obj_src.append(src) return ExtractedObjects(self, obj_src) |