Skip to content

Commit

Permalink
feat: add prealloc linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmtszr committed May 31, 2024
1 parent cd2066c commit cdae629
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ linters:
- unparam
- unused
- whitespace
- prealloc

service:
golangci-lint-version: 1.55.2 # use the fixed version to not introduce new linters unexpectedly
Expand Down
6 changes: 4 additions & 2 deletions couchbase/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,10 @@ func (s *client) GetVBucketSeqNos() (*wrapper.ConcurrentSwissMap[uint16, uint64]
seqNos := wrapper.CreateConcurrentSwissMap[uint16, uint64](1024)

hasCollectionSupport := s.dcpAgent.HasCollectionsSupport()
var collectionIDs []uint32
for collectionID := range s.GetCollectionIDs(s.config.ScopeName, s.config.CollectionNames) {

cIds := s.GetCollectionIDs(s.config.ScopeName, s.config.CollectionNames)
collectionIDs := make([]uint32, 0, len(cIds))
for collectionID := range cIds {
collectionIDs = append(collectionIDs, collectionID)
}
collectionIDSize := len(collectionIDs)
Expand Down
2 changes: 1 addition & 1 deletion couchbase/rollback_mitigation.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (r *rollbackMitigation) loadVbUUID(vbID uint16) error {

r.vbUUIDMap.Store(vbID, failoverLogs[0].VbUUID)

var failoverInfos []string
failoverInfos := make([]string, 0, len(failoverLogs))
for index, failoverLog := range failoverLogs {
failoverInfos = append(
failoverInfos,
Expand Down
2 changes: 1 addition & 1 deletion servicediscovery/service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (s *serviceDiscovery) GetAll() []string {
return s1.ClusterJoinTime < s2.ClusterJoinTime
}).Sort(services)

var names []string
names := make([]string, 0, len(services))

for _, service := range services {
names = append(names, service.Name)
Expand Down

0 comments on commit cdae629

Please sign in to comment.