MCPcopy Create free account
hub / github.com/cel-expr/cel-go / optionalValueSize

Function optionalValueSize

cel/library.go:784–801  ·  view source on GitHub ↗

optionalValueSize returns the size of the value being compared, unwrapping nested optional values to the value they contain, and reporting a size of 1 for values which are not sizable.

(value ref.Val)

Source from the content-addressed store, hash-verified

782// optionalValueSize returns the size of the value being compared, unwrapping nested optional
783// values to the value they contain, and reporting a size of 1 for values which are not sizable.
784func optionalValueSize(value ref.Val) uint64 {
785 for {
786 opt, isOpt := value.(*types.Optional)
787 if !isOpt {
788 break
789 }
790 if !opt.HasValue() {
791 return 1
792 }
793 value = opt.GetValue()
794 }
795 if sizer, isSizer := value.(traits.Sizer); isSizer {
796 if sz, isInt := sizer.Size().(types.Int); isInt {
797 return uint64(sz)
798 }
799 }
800 return 1
801}
802
803// Version returns the current version of the library.
804func (lib *optionalLib) Version() uint32 {

Callers 1

trackOptionalHasValueFunction · 0.85

Calls 3

HasValueMethod · 0.80
GetValueMethod · 0.80
SizeMethod · 0.65

Tested by

no test coverage detected