@@ -498,19 +498,27 @@ func (l *CostEstimator) EstimateCallCost(function, overloadId string, target *ch
498
498
rhs := args [1 ]
499
499
if lhs .Type ().Equal (rhs .Type ()) == types .True {
500
500
t := lhs .Type ()
501
- switch t {
502
- case cel .IPType , cel .CIDRType , cel .QuantityType : // O(1) cost equality checks
503
- return & checker.CallEstimate {CostEstimate : checker.CostEstimate {Min : 1 , Max : 1 }}
504
- case cel .FormatType :
505
- return & checker.CallEstimate {CostEstimate : checker.CostEstimate {Min : 1 , Max : cel .MaxFormatSize }.MultiplyByCostFactor (common .StringTraversalCostFactor )}
506
- case cel .URLType :
507
- size := checker.SizeEstimate {Min : 1 , Max : 1 }
508
- rhSize := rhs .ComputedSize ()
509
- lhSize := rhs .ComputedSize ()
510
- if rhSize != nil && lhSize != nil {
511
- size = rhSize .Union (* lhSize )
501
+ if t .Kind () == types .OpaqueKind {
502
+ switch t .TypeName () {
503
+ case cel .IPType .TypeName (), cel .CIDRType .TypeName ():
504
+ return & checker.CallEstimate {CostEstimate : checker.CostEstimate {Min : 1 , Max : 1 }}
505
+ }
506
+ }
507
+ if t .Kind () == types .StructKind {
508
+ switch t {
509
+ case cel .QuantityType : // O(1) cost equality checks
510
+ return & checker.CallEstimate {CostEstimate : checker.CostEstimate {Min : 1 , Max : 1 }}
511
+ case cel .FormatType :
512
+ return & checker.CallEstimate {CostEstimate : checker.CostEstimate {Min : 1 , Max : cel .MaxFormatSize }.MultiplyByCostFactor (common .StringTraversalCostFactor )}
513
+ case cel .URLType :
514
+ size := checker.SizeEstimate {Min : 1 , Max : 1 }
515
+ rhSize := rhs .ComputedSize ()
516
+ lhSize := rhs .ComputedSize ()
517
+ if rhSize != nil && lhSize != nil {
518
+ size = rhSize .Union (* lhSize )
519
+ }
520
+ return & checker.CallEstimate {CostEstimate : checker.CostEstimate {Min : 1 , Max : size .Max }.MultiplyByCostFactor (common .StringTraversalCostFactor )}
512
521
}
513
- return & checker.CallEstimate {CostEstimate : checker.CostEstimate {Min : 1 , Max : size .Max }.MultiplyByCostFactor (common .StringTraversalCostFactor )}
514
522
}
515
523
}
516
524
}
0 commit comments