Count destination wrappers in shared input limits

This commit is contained in:
2026-10-14 13:31:32 +00:00
parent 2f5d57ce1d
commit c71faf2065
5 changed files with 208 additions and 6 deletions

View File

@@ -86,6 +86,7 @@ func destinationWithinLimits(body *document.Node, destination Path, maxDepth, ma
if segments > maxDepth || segments > maxNodes/2 {
return false
}
wrapperNodes := destinationWrapperNodeCount(destination)
for _, segment := range destination.segments {
if segment.kind != pathSegmentKey {
return false
@@ -94,7 +95,11 @@ func destinationWithinLimits(body *document.Node, destination Path, maxDepth, ma
if documentDepth(body) > maxDepth-segments {
return false
}
return countInputNodes(body) <= maxNodes-2*segments
return countInputNodes(body) <= maxNodes-wrapperNodes
}
func destinationWrapperNodeCount(destination Path) int {
return 2 * len(destination.segments)
}
func documentDepth(node *document.Node) int {