diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2023-10-17 16:47:23 +0200 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-12-29 23:22:14 -0500 |
| commit | a9d7e676e463a30741e9d0df1cfd837e6191df0d (patch) | |
| tree | cde38a49d2d931c690ca5ab75258c5c25be74eab /mesonbuild/utils/universal.py | |
| parent | 08a345758a96892f879b487ee12e3b4e66c33439 (diff) | |
| download | meson-a9d7e676e463a30741e9d0df1cfd837e6191df0d.tar.gz | |
utils: cache build directory files
get_target_generated_sources often calls File.from_built_relative on
the same file, if it is used by many sources. This is a somewhat
expensive call both CPU- and memory-wise, so cache the creation
of build-directory files as well.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Diffstat (limited to 'mesonbuild/utils/universal.py')
| -rw-r--r-- | mesonbuild/utils/universal.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index f26a9a3de..dc327373a 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -402,13 +402,15 @@ class File(HoldableObject): return File(False, subdir, fname) @staticmethod + @lru_cache(maxsize=None) def from_built_file(subdir: str, fname: str) -> 'File': return File(True, subdir, fname) @staticmethod + @lru_cache(maxsize=None) def from_built_relative(relative: str) -> 'File': dirpart, fnamepart = os.path.split(relative) - return File(True, dirpart, fnamepart) + return File.from_built_file(dirpart, fnamepart) @staticmethod def from_absolute_file(fname: str) -> 'File': |
