From 256e910dee90bda81286f31081b56a707f267e0d Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Thu, 7 May 2020 13:37:11 +0200 Subject: [PATCH] cache up regex mathings the names passed in here are often the same. We should ensure that we cache the regex match, as this will speed up our runtime a lot. --- mesonbuild/compilers/compilers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index b0fa5f5b8..ce1016d15 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -138,11 +138,15 @@ def is_llvm_ir(fname): fname = fname.fname return fname.split('.')[-1] == 'll' +@lru_cache(maxsize=None) +def cached_by_name(fname): + suffix = fname.split('.')[-1] + return suffix in obj_suffixes + def is_object(fname): if hasattr(fname, 'fname'): fname = fname.fname - suffix = fname.split('.')[-1] - return suffix in obj_suffixes + return cached_by_name(fname) def is_library(fname): if hasattr(fname, 'fname'):