Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions checker/cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@ func (c *coster) functionCost(e ast.Expr, function, overloadID string, target *A
// O(n) functions
case overloads.ExtFormatString:
if target != nil {
// ResultSize not calculated because we can't bound the max size.
// ResultSize is bounded: since precision is capped by StringsMaxPrecision, // the output cannot exceed the format string size plus the sum of // argument string sizes (each numeric arg expands by at most // maxPrecision + fixed overhead characters).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I can't change these lines and instead would need to move the existing cost caculations into the ext/strings.go implementation and associate it with v0-v4 of the library, and the update written here with the v5+ versions of the library

return CallEstimate{
CostEstimate: c.sizeOrUnknown(*target).MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum())}
targetSz := c.sizeOrUnknown(*target) argsSz := c.sizeOrUnknown(args[0]) resultSize := targetSz.Add(argsSz) return CallEstimate{ CostEstimate: targetSz.MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum()), ResultSize: &resultSize}
}
case overloads.StringToBytes:
if len(args) == 1 {
Expand Down