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:
@@ -25,11 +25,17 @@ type headingBoundary struct {
|
||||
// splitByHeadingsImpl is the Tier-1 implementation. It falls through to the
|
||||
// legacy splitter when the document has no usable heading structure or when
|
||||
// the heading split would produce a single section anyway.
|
||||
func splitByHeadingsImpl(text string, cfg SplitterConfig) []Chunk {
|
||||
//
|
||||
// profile may be nil; we compute one on demand. When the strategy resolver
|
||||
// already ran the profiler (auto strategy), the same profile is threaded
|
||||
// through here so we don't re-scan the entire document.
|
||||
func splitByHeadingsImpl(text string, cfg SplitterConfig, profile *DocProfile) []Chunk {
|
||||
if text == "" {
|
||||
return nil
|
||||
}
|
||||
profile := ProfileDocument(text)
|
||||
if profile == nil {
|
||||
profile = ProfileDocument(text)
|
||||
}
|
||||
primaryLevel := profile.DominantHeadingLevel()
|
||||
if primaryLevel == 0 {
|
||||
return SplitText(text, cfg)
|
||||
|
||||
Reference in New Issue
Block a user