mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
added tree cache
This commit is contained in:
parent
3251380364
commit
851e98a398
1 changed files with 10 additions and 1 deletions
|
@ -360,6 +360,8 @@ class RepoMap:
|
||||||
# Guess a small starting number to help with giant repos
|
# Guess a small starting number to help with giant repos
|
||||||
middle = min(max_map_tokens // 25, num_tags)
|
middle = min(max_map_tokens // 25, num_tags)
|
||||||
|
|
||||||
|
self.tree_cache = dict()
|
||||||
|
|
||||||
while lower_bound <= upper_bound:
|
while lower_bound <= upper_bound:
|
||||||
tree = self.to_tree(ranked_tags[:middle], chat_rel_fnames)
|
tree = self.to_tree(ranked_tags[:middle], chat_rel_fnames)
|
||||||
num_tokens = self.token_count(tree)
|
num_tokens = self.token_count(tree)
|
||||||
|
@ -387,6 +389,11 @@ class RepoMap:
|
||||||
tree_cache = dict()
|
tree_cache = dict()
|
||||||
|
|
||||||
def render_tree(self, abs_fname, rel_fname, lois):
|
def render_tree(self, abs_fname, rel_fname, lois):
|
||||||
|
key = (rel_fname, tuple(sorted(lois)))
|
||||||
|
|
||||||
|
if key in self.tree_cache:
|
||||||
|
return self.tree_cache[key]
|
||||||
|
|
||||||
code = self.io.read_text(abs_fname) or ""
|
code = self.io.read_text(abs_fname) or ""
|
||||||
if not code.endswith("\n"):
|
if not code.endswith("\n"):
|
||||||
code += "\n"
|
code += "\n"
|
||||||
|
@ -407,7 +414,9 @@ class RepoMap:
|
||||||
|
|
||||||
context.add_lines_of_interest(lois)
|
context.add_lines_of_interest(lois)
|
||||||
context.add_context()
|
context.add_context()
|
||||||
return context.format()
|
res = context.format()
|
||||||
|
self.tree_cache[key] = res
|
||||||
|
return res
|
||||||
|
|
||||||
def to_tree(self, tags, chat_rel_fnames):
|
def to_tree(self, tags, chat_rel_fnames):
|
||||||
if not tags:
|
if not tags:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue