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

graphql: dev: chg: avoid greedy allocation on graphql blocks call #958

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,8 @@
return []*Block{}, nil
}

ret := make([]*Block, 0, to-from+1)
// nolint:prealloc
var ret []*Block

Check warning on line 1354 in graphql/graphql.go

View check run for this annotation

Codecov / codecov/patch

graphql/graphql.go#L1354

Added line #L1354 was not covered by tests

for i := from; i <= to; i++ {
numberOrHash := rpc.BlockNumberOrHashWithNumber(i)
Expand All @@ -1370,6 +1371,10 @@
}

ret = append(ret, block)

if err := ctx.Err(); err != nil {
return nil, err

Check warning on line 1376 in graphql/graphql.go

View check run for this annotation

Codecov / codecov/patch

graphql/graphql.go#L1375-L1376

Added lines #L1375 - L1376 were not covered by tests
}
}

return ret, nil
Expand Down