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()
for _, c := range cs {
pHits, ok := m[c.name]
if !ok {
pHits := m[c.name]
if pHits == nil {
nameCopy := strings.Clone(c.name)
hits := uint64(0)
pHits = &hits
@ -128,8 +128,8 @@ func (pfp *pipeFieldNamesProcessor) flush() error {
shards = shards[1:]
for i := range shards {
for name, pHitsSrc := range shards[i].getM() {
pHits, ok := m[name]
if !ok {
pHits := m[name]
if pHits == nil {
m[name] = pHitsSrc
} else {
*pHits += *pHitsSrc

View File

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

View File

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