CmdBuild: Don't use App.res_cache()

App.res_cache should be private. It's needed here to cache the
results of a function which is private to CmdBuild anyway, so solve
that with lru_cache, to allow App to do it's private thing with
caching.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-01-26 12:18:39 +01:00
commit 917f56a814

View file

@ -2,6 +2,7 @@
import os, re, sys, subprocess, datetime, time
from argparse import Namespace, ArgumentParser
from functools import lru_cache
from ...lib.log import *
from ..Cmd import Cmd
@ -25,6 +26,7 @@ class CmdBuild(Cmd): # export
def _run(self, args: Namespace) -> None:
@lru_cache(maxsize=None)
def read_deps(cur, prereq_type):
# dep cache doesn't make a difference at all
if prereq_type in dep_cache:
@ -42,9 +44,6 @@ class CmdBuild(Cmd): # export
dep_cache[prereq_type][cur] = ret
return ret
def read_deps_cached(cur, prereq_type):
return self.app.res_cache.run(read_deps, [ cur, prereq_type ])
def add_dep_tree(cur, prereq_types, tree, all_deps):
log(DEBUG, "adding prerequisites " + ' '.join(prereq_types) + " of module " + cur)
if cur in all_deps:
@ -54,7 +53,7 @@ class CmdBuild(Cmd): # export
all_deps.add(cur)
for t in prereq_types:
log(DEBUG, "checking prereqisites of type " + t)
deps.update(read_deps_cached(cur, t))
deps.update(read_deps(cur, t))
for d in deps:
add_dep_tree(d, prereq_types, tree, all_deps)
tree[cur] = deps