010eda7834
`enclosing_block_boundaries`, `block_range_at` and `summarize_code` each re-parsed the whole file on every call. The results are not cacheable — boundaries depend on the caller's visible ranges, which differ per call — but the `tree_sitter::Tree` is, so cache that instead and hand out `ts_tree_copy` clones. Keyed on (xxh64 of the source, source length, language). The hash is a bucket selector only: a hit re-verifies the stored source against the request byte-for-byte before returning the tree, so a collision costs a re-parse and can never yield a tree built from other content. Language is in the key because the same bytes parsed as TypeScript and as Python are different trees. Bounded at 12 slots and 4 MiB of retained source with LRU eviction; sources above 4 MiB are parsed but never retained. `Tree` is `Send` but not `Sync`, so entries sit behind a `Mutex` that is held only for a map probe, a byte compare and a refcount bump, never across a parse or walk. Error trees are cached like any other: `has_error()` is a property of the tree, so the callers' own checks reach an identical verdict from a cached tree, and repeated "does this parse" probes get the speedup too. Measured (M4 Max, bazel-built .node, median of 20, 1-40 visible): read.ts 81 KB 13.34 ms -> 8.86 ms on repeat; 1 MB synthetic 225.7 ms -> 138.3 ms. Parser::new + set_language measured at 0.30 us against a 3.91 ms parse, so no parser pooling.
77 lines
2.3 KiB
TOML
77 lines
2.3 KiB
TOML
[package]
|
|
name = "pi-ast"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
authors.workspace = true
|
|
repository.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[dependencies]
|
|
anyhow.workspace = true
|
|
ast-grep-core.workspace = true
|
|
globset.workspace = true
|
|
ignore.workspace = true
|
|
phf.workspace = true
|
|
serde.workspace = true
|
|
tree-sitter.workspace = true
|
|
tree-sitter-astro.workspace = true
|
|
tree-sitter-bash.workspace = true
|
|
tree-sitter-c.workspace = true
|
|
tree-sitter-clojure.workspace = true
|
|
tree-sitter-cmake.workspace = true
|
|
tree-sitter-c-sharp.workspace = true
|
|
tree-sitter-cpp.workspace = true
|
|
tree-sitter-dart.workspace = true
|
|
tree-sitter-css.workspace = true
|
|
tree-sitter-diff.workspace = true
|
|
tree-sitter-dockerfile.workspace = true
|
|
tree-sitter-elixir.workspace = true
|
|
tree-sitter-elisp.workspace = true
|
|
tree-sitter-erlang.workspace = true
|
|
tree-sitter-fortran.workspace = true
|
|
tree-sitter-go.workspace = true
|
|
tree-sitter-graphql.workspace = true
|
|
tree-sitter-haskell.workspace = true
|
|
tree-sitter-hcl.workspace = true
|
|
tree-sitter-html.workspace = true
|
|
tree-sitter-ini.workspace = true
|
|
tree-sitter-java.workspace = true
|
|
tree-sitter-javascript.workspace = true
|
|
tree-sitter-json.workspace = true
|
|
tree-sitter-just.workspace = true
|
|
tree-sitter-julia.workspace = true
|
|
tree-sitter-kotlin.workspace = true
|
|
tree-sitter-lua.workspace = true
|
|
tree-sitter-make.workspace = true
|
|
tree-sitter-md.workspace = true
|
|
tree-sitter-nix.workspace = true
|
|
tree-sitter-objc.workspace = true
|
|
tree-sitter-ocaml.workspace = true
|
|
tree-sitter-odin.workspace = true
|
|
tree-sitter-php.workspace = true
|
|
tree-sitter-powershell.workspace = true
|
|
tree-sitter-proto.workspace = true
|
|
tree-sitter-python.workspace = true
|
|
tree-sitter-r.workspace = true
|
|
tree-sitter-regex.workspace = true
|
|
tree-sitter-ruby.workspace = true
|
|
tree-sitter-rust.workspace = true
|
|
tree-sitter-scala.workspace = true
|
|
tree-sitter-solidity.workspace = true
|
|
tree-sitter-sql.workspace = true
|
|
tree-sitter-starlark.workspace = true
|
|
tree-sitter-svelte.workspace = true
|
|
tree-sitter-swift.workspace = true
|
|
tree-sitter-toml-ng.workspace = true
|
|
tree-sitter-tlaplus.workspace = true
|
|
tree-sitter-typescript.workspace = true
|
|
tree-sitter-verilog.workspace = true
|
|
tree-sitter-vue.workspace = true
|
|
tree-sitter-xml.workspace = true
|
|
tree-sitter-yaml.workspace = true
|
|
tree-sitter-zig.workspace = true
|
|
xxhash-rust.workspace = true
|