chore: slices Delete (#24164)
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
parent
f55595fcc9
commit
8cd9b20cbc
@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand" // #nosec // math/rand is used for random selection and seeded from crypto/rand
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"github.com/huandu/skiplist"
|
||||
@ -307,5 +308,5 @@ func (i *senderNonceMempoolIterator) Tx() sdk.Tx {
|
||||
}
|
||||
|
||||
func removeAtIndex[T any](slice []T, index int) []T {
|
||||
return append(slice[:index], slice[index+1:]...)
|
||||
return slices.Delete(slice, index, index+1)
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -159,7 +160,7 @@ func (ubd *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time
|
||||
|
||||
// RemoveEntry - remove entry at index i to the unbonding delegation
|
||||
func (ubd *UnbondingDelegation) RemoveEntry(i int64) {
|
||||
ubd.Entries = append(ubd.Entries[:i], ubd.Entries[i+1:]...)
|
||||
ubd.Entries = slices.Delete(ubd.Entries, int(i), int(i+1))
|
||||
}
|
||||
|
||||
// return the unbonding delegation
|
||||
@ -251,7 +252,7 @@ func (red *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balan
|
||||
|
||||
// RemoveEntry - remove entry at index i to the unbonding delegation
|
||||
func (red *Redelegation) RemoveEntry(i int64) {
|
||||
red.Entries = append(red.Entries[:i], red.Entries[i+1:]...)
|
||||
red.Entries = slices.Delete(red.Entries, int(i), int(i+1))
|
||||
}
|
||||
|
||||
// MustMarshalRED returns the Redelegation bytes. Panics if fails.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user