From 8b6b5584835edbddcedd7e43daa344a7fa549614 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 1 Oct 2024 14:25:27 -0700 Subject: [PATCH] refactor: Optimize cache key generation in RepoMap class --- aider/repomap.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/aider/repomap.py b/aider/repomap.py index 30a538cd3..f0d42e196 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -457,13 +457,18 @@ class RepoMap: force_refresh=False, ): # Create a cache key - cache_key = ( + cache_key = [ tuple(sorted(chat_fnames)) if chat_fnames else None, tuple(sorted(other_fnames)) if other_fnames else None, max_map_tokens, - tuple(sorted(mentioned_fnames)) if mentioned_fnames else None, - tuple(sorted(mentioned_idents)) if mentioned_idents else None, - ) + ] + + if self.refresh == "auto": + cache_key += [ + tuple(sorted(mentioned_fnames)) if mentioned_fnames else None, + tuple(sorted(mentioned_idents)) if mentioned_idents else None, + ] + cache_key = tuple(cache_key) use_cache = False if not force_refresh: