Skip to content

Commit

Permalink
*: Empty maps using built-in clear function
Browse files Browse the repository at this point in the history
It is available starting from Go 1.21.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Sep 2, 2024
1 parent 72baaa1 commit a29e46b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions deploy/alphabet.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ mainLoop:
continue
}

for k := range mRegisteredAlphabetIndices {
delete(mRegisteredAlphabetIndices, k)
}
clear(mRegisteredAlphabetIndices)

for {
candidates, err := iterCandidates.Next(len(alphabet) - len(mRegisteredAlphabetIndices))
Expand Down
4 changes: 1 addition & 3 deletions deploy/notary.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ func initDesignateNotaryRoleAsLeaderTick(ctx context.Context, prm enableNotaryPr

resetTx := func() {
tx = nil
for k := range mCommitteeIndexToSignature {
delete(mCommitteeIndexToSignature, k)
}
clear(mCommitteeIndexToSignature)
txFullySigned = false
setDomainRecordTxMonitor.reset()
designateRoleTxMonitor.reset()
Expand Down
4 changes: 1 addition & 3 deletions tests/dump/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ func (x *Reader) fromDumpStreams(rContracts, rStorageItems io.Reader) error {
_csv.ReuseRecord = true

if x.mStorage != nil {
for k := range x.mStorage {
delete(x.mStorage, k)
}
clear(x.mStorage)
} else {
x.mStorage = make(map[string][]kv)
}
Expand Down

0 comments on commit a29e46b

Please sign in to comment.