Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(all): add prealloc #17

Merged
merged 1 commit into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
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 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