Skip to content

Commit

Permalink
perf(all): add prealloc
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamelentyev authored and thepudds committed Jan 9, 2022
1 parent 91dd791 commit 87c9f72
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions fuzzer/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (fz *Fuzzer) chain(steps []Step, pl plan.Plan) {
// Second, create our list of execCalls based on the list of plan.Calls.
// We do not yet fully populate the arguments for an execCall,
// which we will do on a subsequent pass.
var execCalls []execCall
execCalls := make([]execCall, len(pl.Calls))
for i := range pl.Calls {
// Based on the plan, compute index into the user's Step list.
s := int(pl.Calls[i].StepIndex) % len(steps)
Expand All @@ -281,7 +281,7 @@ func (fz *Fuzzer) chain(steps []Step, pl plan.Plan) {
args: []argument{}, // empty to start, we will fill in below.
}

execCalls = append(execCalls, ec)
execCalls[i] = ec
}

// Third, create arguments as needed for each execCall,
Expand Down
4 changes: 2 additions & 2 deletions gen/genfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ func emitIndependentWrapper(emit emitFunc, function mod.Func, constructors []mod
return fmt.Errorf("%w: %s has 0 input params", errNoFunctionsMatch, function.FuncName)
}

var paramReprs []paramRepr
paramReprs := make([]paramRepr, len(inputParams))
for i, v := range inputParams {
typeStringWithSelector := types.TypeString(v.Type(), defaultQualifier)
paramName := avoidCollision(v, i, localPkg, inputParams)
paramReprs = append(paramReprs, paramRepr{paramName: paramName, typ: typeStringWithSelector, v: v})
paramReprs[i] = paramRepr{paramName: paramName, typ: typeStringWithSelector, v: v}
}

// Check if we have an interface or function pointer in our desired parameters,
Expand Down
8 changes: 4 additions & 4 deletions gen/genfuncsloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ func emitChainTarget(emit emitFunc, function mod.Func, qualifyAll bool) error {
inputParams = append(inputParams, v)
}

var paramReprs []paramRepr
paramReprs := make([]paramRepr, len(inputParams))
for i, v := range inputParams {
typeStringWithSelector := types.TypeString(v.Type(), defaultQualifier)
paramName := avoidCollision(v, i, localPkg, inputParams)
paramReprs = append(paramReprs, paramRepr{paramName: paramName, typ: typeStringWithSelector, v: v})
paramReprs[i] = paramRepr{paramName: paramName, typ: typeStringWithSelector, v: v}
}

// Check if we have an interface or function pointer in our desired parameters,
Expand Down Expand Up @@ -458,11 +458,11 @@ func emitChainStep(emit emitFunc, function mod.Func, constructor mod.Func, quali
inputParams = append(inputParams, v)
}

var paramReprs []paramRepr
paramReprs := make([]paramRepr, len(inputParams))
for i, v := range inputParams {
typeStringWithSelector := types.TypeString(v.Type(), defaultQualifier)
paramName := avoidCollision(v, i, localPkg, inputParams)
paramReprs = append(paramReprs, paramRepr{paramName: paramName, typ: typeStringWithSelector, v: v})
paramReprs[i] = paramRepr{paramName: paramName, typ: typeStringWithSelector, v: v}
}

// Check if we have an interface or function pointer in our desired parameters,
Expand Down

0 comments on commit 87c9f72

Please sign in to comment.