lib/logstorage: consistently use "pHits := m[..]" pattern

Consistency improves maintainability of the code a bit.
This commit is contained in:
Aliaksandr Valialkin 2024-10-18 00:30:00 +02:00
parent 2023f017b1
commit 1892e357c3
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
3 changed files with 10 additions and 10 deletions

View file

@ -103,8 +103,8 @@ func (pfp *pipeFieldNamesProcessor) writeBlock(workerID uint, br *blockResult) {
cs := br.getColumns() cs := br.getColumns()
for _, c := range cs { for _, c := range cs {
pHits, ok := m[c.name] pHits := m[c.name]
if !ok { if pHits == nil {
nameCopy := strings.Clone(c.name) nameCopy := strings.Clone(c.name)
hits := uint64(0) hits := uint64(0)
pHits = &hits pHits = &hits
@ -128,8 +128,8 @@ func (pfp *pipeFieldNamesProcessor) flush() error {
shards = shards[1:] shards = shards[1:]
for i := range shards { for i := range shards {
for name, pHitsSrc := range shards[i].getM() { for name, pHitsSrc := range shards[i].getM() {
pHits, ok := m[name] pHits := m[name]
if !ok { if pHits == nil {
m[name] = pHitsSrc m[name] = pHitsSrc
} else { } else {
*pHits += *pHitsSrc *pHits += *pHitsSrc

View file

@ -217,8 +217,8 @@ func (shard *pipeUniqProcessorShard) writeBlock(br *blockResult) bool {
func (shard *pipeUniqProcessorShard) updateState(v string, hits uint64) { func (shard *pipeUniqProcessorShard) updateState(v string, hits uint64) {
m := shard.getM() m := shard.getM()
pHits, ok := m[v] pHits := m[v]
if !ok { if pHits == nil {
vCopy := strings.Clone(v) vCopy := strings.Clone(v)
hits := uint64(0) hits := uint64(0)
pHits = &hits pHits = &hits

View file

@ -337,8 +337,8 @@ func (s *Storage) GetStreamFieldNames(ctx context.Context, tenantIDs []TenantID,
m := make(map[string]*uint64) m := make(map[string]*uint64)
forEachStreamField(streams, func(f Field, hits uint64) { forEachStreamField(streams, func(f Field, hits uint64) {
pHits, ok := m[f.Name] pHits := m[f.Name]
if !ok { if pHits == nil {
nameCopy := strings.Clone(f.Name) nameCopy := strings.Clone(f.Name)
hitsLocal := uint64(0) hitsLocal := uint64(0)
pHits = &hitsLocal pHits = &hitsLocal
@ -364,8 +364,8 @@ func (s *Storage) GetStreamFieldValues(ctx context.Context, tenantIDs []TenantID
if f.Name != fieldName { if f.Name != fieldName {
return return
} }
pHits, ok := m[f.Value] pHits := m[f.Value]
if !ok { if pHits == nil {
valueCopy := strings.Clone(f.Value) valueCopy := strings.Clone(f.Value)
hitsLocal := uint64(0) hitsLocal := uint64(0)
pHits = &hitsLocal pHits = &hitsLocal