trackStringReplaceCost tracks runtime cost for string replace operations, accounting for search cost and the size of the result.
(args []ref.Val, result ref.Val)
| 1053 | // trackStringReplaceCost tracks runtime cost for string replace operations, |
| 1054 | // accounting for search cost and the size of the result. |
| 1055 | func trackStringReplaceCost(args []ref.Val, result ref.Val) *uint64 { |
| 1056 | targetSize := actualSize(args[0]) |
| 1057 | if targetSize == 0 { |
| 1058 | targetSize = 1 |
| 1059 | } |
| 1060 | needleSize := actualSize(args[1]) |
| 1061 | if needleSize == 0 { |
| 1062 | needleSize = 1 |
| 1063 | } |
| 1064 | searchCost := uint64(math.Ceil(float64(targetSize*needleSize) * stringCostFactor)) |
| 1065 | cost := safeAdd(callCost, searchCost, actualSize(result)) |
| 1066 | return &cost |
| 1067 | } |
| 1068 | |
| 1069 | // trackStringSplitCost tracks runtime cost for string split operations, |
| 1070 | // accounting for traversal and list allocation. |
nothing calls this directly
no test coverage detected