Skip to content

Conversation

@Fibonacci747
Copy link
Contributor

Previously ObserveGossipTopicSeen called GetOrCreateCounter twice for every new gossip topic and performed an extra Store into gossipMetricsMap. This added unnecessary work and potential allocations on first use of each topic without changing the behavior of the metrics.

This change simplifies ObserveGossipTopicSeen to rely solely on the value returned by sync.Map.LoadOrStore, removing the redundant second GetOrCreateCounter call and duplicate Store. The semantics of the metric and its caching remain the same while eliminating the extra overhead on metric initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant