[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 33ee3e588fd: Fix regression of treesit_cursor_helper_1
From: |
Yuan Fu |
Subject: |
emacs-29 33ee3e588fd: Fix regression of treesit_cursor_helper_1 |
Date: |
Mon, 11 Sep 2023 18:17:28 -0400 (EDT) |
branch: emacs-29
commit 33ee3e588fd9744714f1c0ab64de75a61db5eaca
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix regression of treesit_cursor_helper_1
* src/treesit.c (treesit_cursor_helper_1)
(treesit_cursor_first_child_for_byte): Use
ts_tree_cursor_goto_first_child_for_byte first, and
ts_tree_cursor_goto_first_child second.
---
src/treesit.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/treesit.c b/src/treesit.c
index cb2113b3faf..8419452d54a 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -2160,7 +2160,10 @@ return nil. */)
static bool treesit_cursor_first_child_for_byte
(TSTreeCursor *cursor, ptrdiff_t pos, bool named)
{
- if (!ts_tree_cursor_goto_first_child (cursor))
+ /* ts_tree_cursor_goto_first_child_for_byte is significantly faster,
+ so despite it having problems, we try it first. */
+ if (ts_tree_cursor_goto_first_child_for_byte (cursor, pos) == -1
+ && !ts_tree_cursor_goto_first_child (cursor))
return false;
TSNode node = ts_tree_cursor_current_node (cursor);
@@ -2890,7 +2893,11 @@ treesit_cursor_helper_1 (TSTreeCursor *cursor, TSNode
*target,
if (ts_node_eq (cursor_node, *target))
return true;
- if (ts_tree_cursor_goto_first_child_for_byte (cursor, start_pos) == -1)
+ /* ts_tree_cursor_goto_first_child_for_byte is significantly faster,
+ so despite it having problems (see bug#60127), we try it
+ first. */
+ if (ts_tree_cursor_goto_first_child_for_byte (cursor, start_pos) == -1
+ && !ts_tree_cursor_goto_first_child (cursor))
return false;
/* Go through each sibling that could contain TARGET. Because of
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 33ee3e588fd: Fix regression of treesit_cursor_helper_1,
Yuan Fu <=