Skip to content

Commit

Permalink
chore(x/gov): reduce allocations (cosmos#20207)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 authored Apr 30, 2024
1 parent 71adab7 commit 19e4884
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions x/gov/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ func NormalizeProposalType(proposalType string) v1.ProposalType {

// NormalizeWeightedVoteOptions - normalize vote options param string
func NormalizeWeightedVoteOptions(options string) string {
newOptions := []string{}
for _, option := range strings.Split(options, ",") {
tmpOptions := strings.Split(options, ",")
newOptions := make([]string, 0, len(tmpOptions))
for _, option := range tmpOptions {
fields := strings.Split(option, "=")
fields[0] = NormalizeVoteOption(fields[0])
if len(fields) < 2 {
Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (k Keeper) validateInitialDeposit(params v1.Params, initialDeposit sdk.Coin

// validateDepositDenom validates if the deposit denom is accepted by the governance module.
func (k Keeper) validateDepositDenom(params v1.Params, depositAmount sdk.Coins) error {
denoms := []string{}
denoms := make([]string, 0, len(params.MinDeposit))
acceptedDenoms := make(map[string]bool, len(params.MinDeposit))
for _, coin := range params.MinDeposit {
acceptedDenoms[coin.Denom] = true
Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata
}
}

msgs := []string{} // will hold a string slice of all Msg type URLs.
msgs := make([]string, 0, len(messages)) // will hold a string slice of all Msg type URLs.

// Loop through all messages and confirm that each has a handler and the gov module account as the only signer
for _, msg := range messages {
Expand Down

0 comments on commit 19e4884

Please sign in to comment.