Skip to content

Commit

Permalink
Hoist code out of the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
neitdung committed Oct 17, 2023
1 parent a24dc70 commit ea1e210
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x/interchainstaking/keeper/address_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ func (k Keeper) IterateUserMappedAccounts(ctx sdk.Context, localAddress []byte,
defer iterator.Close()

i := int64(0)
remoteAddrPrefixLen := len(types.GetRemoteAddressPrefix(localAddress))
for ; iterator.Valid(); iterator.Next() {
value := iterator.Value()
key := iterator.Key()
chainIDBytes := key[len(types.GetRemoteAddressPrefix(localAddress)):]
chainIDBytes := key[remoteAddrPrefixLen:]
stop := fn(i, string(chainIDBytes), value)
if stop {
break
Expand Down

0 comments on commit ea1e210

Please sign in to comment.