chore(all): replace map key deletion loop with clear() (#21082)

This commit is contained in:
Name 2025-04-01 23:28:06 +08:00 committed by GitHub
parent e0c8738230
commit b1bc641105
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 18 deletions

View File

@ -647,9 +647,7 @@ func (sys *BucketMetadataSys) init(ctx context.Context, buckets []string) {
// Reset the state of the BucketMetadataSys. // Reset the state of the BucketMetadataSys.
func (sys *BucketMetadataSys) Reset() { func (sys *BucketMetadataSys) Reset() {
sys.Lock() sys.Lock()
for k := range sys.metadataMap { clear(sys.metadataMap)
delete(sys.metadataMap, k)
}
sys.Unlock() sys.Unlock()
} }

View File

@ -491,13 +491,9 @@ func (config *TierConfigMgr) Reload(ctx context.Context, objAPI ObjectLayer) err
} }
// Reset drivercache built using current config // Reset drivercache built using current config
for k := range config.drivercache { clear(config.drivercache)
delete(config.drivercache, k)
}
// Remove existing tier configs // Remove existing tier configs
for k := range config.Tiers { clear(config.Tiers)
delete(config.Tiers, k)
}
// Copy over the new tier configs // Copy over the new tier configs
for tier, cfg := range newConfig.Tiers { for tier, cfg := range newConfig.Tiers {
config.Tiers[tier] = cfg config.Tiers[tier] = cfg

View File

@ -3373,9 +3373,7 @@ func (s *xlStorage) CleanAbandonedData(ctx context.Context, volume string, path
} }
// Clear and repopulate // Clear and repopulate
for k := range foundDirs { clear(foundDirs)
delete(foundDirs, k)
}
// Populate into map // Populate into map
for _, k := range dirs { for _, k := range dirs {

View File

@ -132,9 +132,7 @@ func (m *MSS) Msgsize() int {
// NewMSS returns a new MSS. // NewMSS returns a new MSS.
func NewMSS() *MSS { func NewMSS() *MSS {
m := MSS(mssPool.Get()) m := MSS(mssPool.Get())
for k := range m { clear(m)
delete(m, k)
}
return &m return &m
} }

View File

@ -87,9 +87,7 @@ func (r *Record) Reset() {
if len(r.csvRecord) > 0 { if len(r.csvRecord) > 0 {
r.csvRecord = r.csvRecord[:0] r.csvRecord = r.csvRecord[:0]
} }
for k := range r.nameIndexMap { clear(r.nameIndexMap)
delete(r.nameIndexMap, k)
}
} }
// Clone the record. // Clone the record.