mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/logstorage: consistently use "pHits := m[..]" pattern
Consistency improves maintainability of the code a bit.
This commit is contained in:
parent
2023f017b1
commit
1892e357c3
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user