mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 15:36:29 -04:00
**Problem:** `query.c` compares the current analysis state with the previous analysis state to see if they are equal, so that it can return early if so. This prevents redundant work. However, the comparison function here differs from the one used for sorted insertion/lookup in that it does not check any state data other than the child index. This is problematic because it leads to infinite analysis when hidden nodes have cycles. **Solution:** Remove the custom comparison function, and apply the insertion/lookup comparison function in place of it. **NOTE:** This commit also changes the comparison function slightly, so that some comparisons are reordered. Namely, for performance, it returns early if the lhs depth is less than the rhs depth. Is this acceptable? Tests still pass and nothing hangs in my testing, but it still seems sketchy. Returning early if the lhs depth is greater than the rhs depth does seem to make query analysis hang, weirdly enough... Keeping the depth checks at the end of the loop also works, but it introduces a noticeable performance regression (for queries that otherwise wouldn't have had analysis cycles, of course). |
||
|---|---|---|
| .. | ||
| portable | ||
| unicode | ||
| wasm | ||
| alloc.c | ||
| alloc.h | ||
| array.h | ||
| atomic.h | ||
| clock.h | ||
| error_costs.h | ||
| get_changed_ranges.c | ||
| get_changed_ranges.h | ||
| host.h | ||
| language.c | ||
| language.h | ||
| length.h | ||
| lexer.c | ||
| lexer.h | ||
| lib.c | ||
| node.c | ||
| parser.c | ||
| parser.h | ||
| point.h | ||
| query.c | ||
| reduce_action.h | ||
| reusable_node.h | ||
| stack.c | ||
| stack.h | ||
| subtree.c | ||
| subtree.h | ||
| tree.c | ||
| tree.h | ||
| tree_cursor.c | ||
| tree_cursor.h | ||
| ts_assert.h | ||
| unicode.h | ||
| wasm_store.c | ||
| wasm_store.h | ||