[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 f711f4e99f7: (Ftreesit_query_capture): Cache list of predicates
From: |
Dmitry Gutov |
Subject: |
emacs-29 f711f4e99f7: (Ftreesit_query_capture): Cache list of predicates for given pattern index |
Date: |
Tue, 31 Jan 2023 20:46:11 -0500 (EST) |
branch: emacs-29
commit f711f4e99f7f2b213e70d14c808261b93ed10c36
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
(Ftreesit_query_capture): Cache list of predicates for given pattern index
* src/treesit.c (Ftreesit_query_capture):
Cache list of predicates for given pattern index (bug#60953).
---
src/treesit.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/treesit.c b/src/treesit.c
index b210ec0923a..a5815903b4d 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -2720,8 +2720,10 @@ the query. */)
every for loop and nconc it to RESULT every time. That is indeed
the initial implementation in which Yoav found nconc being the
bottleneck (98.4% of the running time spent on nconc). */
+ uint32_t patterns_count = ts_query_pattern_count (treesit_query);
Lisp_Object result = Qnil;
Lisp_Object prev_result = result;
+ Lisp_Object predicates_table = make_vector (patterns_count, Qt);
while (ts_query_cursor_next_match (cursor, &match))
{
/* Record the checkpoint that we may roll back to. */
@@ -2750,9 +2752,12 @@ the query. */)
result = Fcons (cap, result);
}
/* Get predicates. */
- Lisp_Object predicates
- = treesit_predicates_for_pattern (treesit_query,
- match.pattern_index);
+ Lisp_Object predicates = AREF (predicates_table, match.pattern_index);
+ if (EQ (predicates, Qt))
+ {
+ predicates = treesit_predicates_for_pattern (treesit_query, 0);
+ ASET (predicates_table, match.pattern_index, predicates);
+ }
/* captures_lisp = Fnreverse (captures_lisp); */
struct capture_range captures_range = { result, prev_result };
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 f711f4e99f7: (Ftreesit_query_capture): Cache list of predicates for given pattern index,
Dmitry Gutov <=