Skip to content

Commit a9d7e67

Browse files
bonzinieli-schwartz
authored andcommitted
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>
1 parent 08a3457 commit a9d7e67

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mesonbuild/utils/universal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,15 @@ def from_source_file(source_root: str, subdir: str, fname: str) -> 'File':
402402
return File(False, subdir, fname)
403403

404404
@staticmethod
405+
@lru_cache(maxsize=None)
405406
def from_built_file(subdir: str, fname: str) -> 'File':
406407
return File(True, subdir, fname)
407408

408409
@staticmethod
410+
@lru_cache(maxsize=None)
409411
def from_built_relative(relative: str) -> 'File':
410412
dirpart, fnamepart = os.path.split(relative)
411-
return File(True, dirpart, fnamepart)
413+
return File.from_built_file(dirpart, fnamepart)
412414

413415
@staticmethod
414416
def from_absolute_file(fname: str) -> 'File':

0 commit comments

Comments
 (0)