From ff7a997f484deda3e355e5697eea220d6001814b Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 11 Dec 2023 12:49:43 -0500 Subject: xcode backend: make the type of get_target_dir align with parent class mypy will complain if backends.Backend has a lru_cache wrapped method, but it is overridden in XCodeBackend with a method that isn't cached. This is almost certainly a sign that we should be caching it here too anyway. The generic backend cache was added years ago via an intimidating commit f39d2cc3bfa1dd4983cbe5adfb6c6e87dd09d684 which claims that it reduced call time from 60s to 0.000435s and that this was specifically due to getting a coredata option every single time. This is probably workload dependent, but getting an option is *not* nearly as cheap as a throwaway function call. --- mesonbuild/backend/xcodebackend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 104527a91..7d77b4fb0 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -13,7 +13,7 @@ # limitations under the License. from __future__ import annotations -import uuid, os, operator +import functools, uuid, os, operator import typing as T from . import backends @@ -226,6 +226,7 @@ class XCodeBackend(backends.Backend): def gen_id(self) -> str: return str(uuid.uuid4()).upper().replace('-', '')[:24] + @functools.lru_cache(maxsize=None) def get_target_dir(self, target): dirname = os.path.join(target.get_subdir(), T.cast('str', self.environment.coredata.get_option(OptionKey('buildtype')))) #os.makedirs(os.path.join(self.environment.get_build_dir(), dirname), exist_ok=True) -- cgit v1.2.3