Commit b4e3be33 authored by Gabriel Russo's avatar Gabriel Russo Committed by Facebook Github Bot

Fix warnings

Summary:
`-Wrange-loop-analysis` complains about the unnecessary copy.

```
In file included from servicerouter/common/InstanceCount.h:9:
folly/experimental/SingletonRelaxedCounter.h:77:21: error: loop variable 'kvp' of type 'const std::pair<std::atomic<long> *const, unsigned long>' creates a copy from type 'const std::pair<std::atomic<long> *const
, unsigned long>' [-Werror,-Wrange-loop-analysis]
    for (auto const kvp : tracking->locals) {

...

folly/experimental/SingletonRelaxedCounter.h:77:10: note: use reference type 'const std::pair<std::atomic<long> *const, unsigned long> &' to prevent copying
    for (auto const kvp : tracking->locals) {
```

Reviewed By: stepancheg

Differential Revision: D19554423

fbshipit-source-id: 742dd4e7d144dd2dd0c888236b85f222373e9e54
parent 135cff30
...@@ -74,7 +74,7 @@ class SingletonRelaxedCounter { ...@@ -74,7 +74,7 @@ class SingletonRelaxedCounter {
auto const& global = Global::instance(); auto const& global = Global::instance();
auto count = global.fallback.load(std::memory_order_relaxed); auto count = global.fallback.load(std::memory_order_relaxed);
auto const tracking = global.tracking.rlock(); auto const tracking = global.tracking.rlock();
for (auto const kvp : tracking->locals) { for (auto const& kvp : tracking->locals) {
count += kvp.first->load(std::memory_order_relaxed); count += kvp.first->load(std::memory_order_relaxed);
} }
return std::is_unsigned<Int>::value return std::is_unsigned<Int>::value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment