perf(chunker): thread DocProfile through splitter dispatch

Strategy.Split / SplitWithDiagnostics already run ProfileDocument once
when the auto strategy resolves the chain. splitByHeadingsImpl was
rerunning the same O(N) pass on entry, so every auto-mode call paid
2x scan cost; SplitParentChild paid 2x per parent.

Pass the profile down through runTier and let splitters compute their
own only when called outside the auto path (where profile == nil).
This commit is contained in:
wizardchen
2026-05-06 20:56:01 +08:00
committed by lyingbug
parent 5a79a817a1
commit 151e999db1
5 changed files with 48 additions and 32 deletions
@@ -27,7 +27,11 @@ type boundary struct {
// splitByHeuristicsImpl is the Tier-2 implementation. Falls through to the
// legacy splitter when no heuristic boundaries are found.
func splitByHeuristicsImpl(text string, cfg SplitterConfig) []Chunk {
//
// profile is currently unused (this tier scans for boundaries directly) but
// is accepted to keep the splitByHeadings / splitByHeuristics signatures
// uniform — see strategy.runTier.
func splitByHeuristicsImpl(text string, cfg SplitterConfig, _ *DocProfile) []Chunk {
if text == "" {
return nil
}