File tree Expand file tree Collapse file tree 1 file changed +15
-16
lines changed Expand file tree Collapse file tree 1 file changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -668,23 +668,22 @@ func estimateFnArgsCount(program *Program) int {
668
668
// operations, but this is just an estimation
669
669
var count int
670
670
for _ , op := range program .Bytecode {
671
- switch op {
672
- case OpCall1 :
673
- count ++
674
- case OpCall2 :
675
- count += 2
676
- case OpCall3 :
677
- count += 3
678
- case OpCallN :
679
- // we don't know exactly but we know at least 4, so be conservative
680
- // as this is only an optimization and we also want to avoid
681
- // excessive preallocation
682
- count += 4
683
- case OpCallFast , OpCallSafe :
684
- // here we don't know either, but we can guess it could be common to
685
- // receive up to 3 arguments in a function
686
- count += 3
671
+ if int (op ) < len (opArgLenEstimation ) {
672
+ count += opArgLenEstimation [op ]
687
673
}
688
674
}
689
675
return count
690
676
}
677
+
678
+ var opArgLenEstimation = [... ]int {
679
+ OpCall1 : 1 ,
680
+ OpCall2 : 2 ,
681
+ OpCall3 : 3 ,
682
+ // we don't know exactly but we know at least 4, so be conservative as this
683
+ // is only an optimization and we also want to avoid excessive preallocation
684
+ OpCallN : 4 ,
685
+ // here we don't know either, but we can guess it could be common to receive
686
+ // up to 3 arguments in a function
687
+ OpCallFast : 3 ,
688
+ OpCallSafe : 3 ,
689
+ }
You can’t perform that action at this time.
0 commit comments