mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 01:04:59 +00:00
feat: Add cache for get_ranked_tags_map
This commit is contained in:
parent
dfe4f4827c
commit
bcbaac03d4
1 changed files with 21 additions and 0 deletions
|
@ -34,6 +34,10 @@ class RepoMap:
|
||||||
|
|
||||||
tokens_per_char = None
|
tokens_per_char = None
|
||||||
|
|
||||||
|
# Cache for get_ranked_tags_map
|
||||||
|
_last_ranked_tags_map = None
|
||||||
|
_last_ranked_tags_map_args = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
map_tokens=1024,
|
map_tokens=1024,
|
||||||
|
@ -409,6 +413,18 @@ class RepoMap:
|
||||||
mentioned_fnames=None,
|
mentioned_fnames=None,
|
||||||
mentioned_idents=None,
|
mentioned_idents=None,
|
||||||
):
|
):
|
||||||
|
# Check if the arguments match the last call
|
||||||
|
current_args = (
|
||||||
|
tuple(chat_fnames),
|
||||||
|
tuple(other_fnames) if other_fnames else None,
|
||||||
|
max_map_tokens,
|
||||||
|
frozenset(mentioned_fnames) if mentioned_fnames else None,
|
||||||
|
frozenset(mentioned_idents) if mentioned_idents else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
if current_args == self._last_ranked_tags_map_args:
|
||||||
|
return self._last_ranked_tags_map
|
||||||
|
|
||||||
if not other_fnames:
|
if not other_fnames:
|
||||||
other_fnames = list()
|
other_fnames = list()
|
||||||
if not max_map_tokens:
|
if not max_map_tokens:
|
||||||
|
@ -473,6 +489,11 @@ class RepoMap:
|
||||||
middle = (lower_bound + upper_bound) // 2
|
middle = (lower_bound + upper_bound) // 2
|
||||||
|
|
||||||
spin.end()
|
spin.end()
|
||||||
|
|
||||||
|
# Cache the result
|
||||||
|
self._last_ranked_tags_map = best_tree
|
||||||
|
self._last_ranked_tags_map_args = current_args
|
||||||
|
|
||||||
return best_tree
|
return best_tree
|
||||||
|
|
||||||
tree_cache = dict()
|
tree_cache = dict()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue