Skip to content

Commit

Permalink
feat(indexer): Preallocate space for a slice
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Cory authored and Will Cory committed Aug 15, 2023
1 parent e5e5004 commit 6f87ca8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion indexer/api/routes/deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type DepositResponse struct {
// TODO this is original spec but maybe include the l2 block info too for the relayed tx
// FIXME make a pure function that returns a struct instead of newWithdrawalResponse
func newDepositResponse(deposits []*database.L1BridgeDepositWithTransactionHashes) DepositResponse {
var items []DepositItem
items := make([]DepositItem, len(deposits))
for _, deposit := range deposits {
item := DepositItem{
Guid: deposit.L1BridgeDeposit.TransactionSourceHash.String(),
Expand Down
2 changes: 1 addition & 1 deletion indexer/api/routes/withdrawals.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type WithdrawalResponse struct {

// FIXME make a pure function that returns a struct instead of newWithdrawalResponse
func newWithdrawalResponse(withdrawals []*database.L2BridgeWithdrawalWithTransactionHashes) WithdrawalResponse {
var items []WithdrawalItem
items := make([]WithdrawalItem, len(withdrawals))
for _, withdrawal := range withdrawals {
item := WithdrawalItem{
Guid: withdrawal.L2BridgeWithdrawal.TransactionWithdrawalHash.String(),
Expand Down

0 comments on commit 6f87ca8

Please sign in to comment.