From a941c5cb82410505d244a1a69a57b30a0f036c84 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 19 Oct 2023 13:13:48 -0700 Subject: [PATCH] cache tags --- aider/repomap.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/aider/repomap.py b/aider/repomap.py index 001d1e94f..69792b95f 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -156,6 +156,25 @@ class RepoMap: self.io.tool_error(f"File not found error: {fname}") def get_tags(self, fname, rel_fname): + # Check if the file is in the cache and if the modification time has not changed + file_mtime = self.get_mtime(fname) + if file_mtime is None: + return [] + + cache_key = fname + if cache_key in self.TAGS_CACHE and self.TAGS_CACHE[cache_key]["mtime"] == file_mtime: + return self.TAGS_CACHE[cache_key]["data"] + + # miss! + + data = list(self.get_tags_raw(fname, rel_fname)) + + # Update the cache + self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data} + self.save_tags_cache() + return data + + def get_tags_raw(self, fname, rel_fname): lang = filename_to_lang(fname) if not lang: return