MCPcopy
hub / github.com/go-yaml/yaml / allowedAliasRatio

Function allowedAliasRatio

decode.go:468–482  ·  view source on GitHub ↗
(decodeCount int)

Source from the content-addressed store, hash-verified

466)
467
468func allowedAliasRatio(decodeCount int) float64 {
469 switch {
470 case decodeCount <= alias_ratio_range_low:
471 // allow 99% to come from alias expansion for small-to-medium documents
472 return 0.99
473 case decodeCount >= alias_ratio_range_high:
474 // allow 10% to come from alias expansion for very large documents
475 return 0.10
476 default:
477 // scale smoothly from 99% down to 10% over the range.
478 // this maps to 396,000 - 400,000 allowed alias-driven decodes over the range.
479 // 400,000 decode operations is ~100MB of allocations in worst-case scenarios (single-item maps).
480 return 0.99 - 0.89*(float64(decodeCount-alias_ratio_range_low)/alias_ratio_range)
481 }
482}
483
484func (d *decoder) unmarshal(n *Node, out reflect.Value) (good bool) {
485 d.decodeCount++

Callers 1

unmarshalMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected