Commit 548a5ec
authored
perf(parser): rewrite Walk to use TreeCursor (Task B1) (#146)
Replaces the recursive Node.Child(i) traversal with an iterative
tree-sitter TreeCursor walk. Matches the canonical tree-sitter idiom
and removes Go-level recursion frames per descent.
Honest accounting: smacker's *TreeCursor.CurrentNode() still routes
through Tree.cachedNode, so the per-visit *Node allocation is
unchanged. The 91%-of-allocations cachedNode hot spot pprof flagged
on airflow was driven by per-node *re-parse* (Task A1 fixed that by
parsing once per file). Phase B's structural change keeps the public
Walk(root, fn) API identical; callers and tests are untouched.
Plan: docs/superpowers/plans/2026-05-13-enrich-oom-fix.md Task B1.
Verification:
- go test ./internal/parser/... ./internal/intelligence/extractor/... pass
- go test ./... -count=1: 877 pass (unchanged from main)
- Determinism preserved: pre-order DFS visitation order matches the
recursive form exactly.1 parent 9f54673 commit 548a5ec
1 file changed
Lines changed: 33 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
31 | 59 | | |
32 | 60 | | |
33 | 61 | | |
| |||
0 commit comments