diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-04-01 05:05:55 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-04-01 05:09:45 -0600 |
commit | 8eec957275cb3566b8371774a9a1e3e09f43fcde (patch) | |
tree | 5e12965529506185eaf895150d0d425f83e5d10a /build-aux/measurestack/analyze.py | |
parent | c004342a27fb135b5d3fcd6817be4a2ae588668b (diff) |
measurestack: Cache resolve_funcname()
Diffstat (limited to 'build-aux/measurestack/analyze.py')
-rw-r--r-- | build-aux/measurestack/analyze.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/build-aux/measurestack/analyze.py b/build-aux/measurestack/analyze.py index b7b8b08..5b29841 100644 --- a/build-aux/measurestack/analyze.py +++ b/build-aux/measurestack/analyze.py @@ -174,7 +174,12 @@ class _Graph: graph: dict[QName, Node] qualified: dict[BaseName, QName] - def resolve_funcname(self, funcname: QName) -> QName | None: + _resolve_cache: dict[QName, QName | None] + + def __init__(self) -> None: + self._resolve_cache = {} + + def _resolve_funcname(self, funcname: QName) -> QName | None: s = str(funcname) is_qualified = ":" in s @@ -198,6 +203,11 @@ class _Graph: return None + def resolve_funcname(self, funcname: QName) -> QName | None: + if funcname not in self._resolve_cache: + self._resolve_cache[funcname] = self._resolve_funcname(funcname) + return self._resolve_cache[funcname] + def _make_graph( ci_fnames: typing.Collection[str], |