@@ -1378,15 +1378,8 @@ class DynamicTimeseriesWrapper {
1378
1378
// E.g. add(1, "red", "cat");
1379
1379
// add(2, "red", 42);
1380
1380
template <typename ... Args>
1381
- void add (int64_t value, Args&&... subkeys) {
1382
- auto key = key_.getFormattedKeyWithExtra (std::forward<Args>(subkeys)...);
1383
- if (key.second .get () == nullptr ) {
1384
- ThreadCachedServiceData::ThreadLocalStatsMap& tcData =
1385
- *ThreadCachedServiceData::getStatsThreadLocal ();
1386
- // Cache thread local counter
1387
- key.second .get () = tcData.getTimeseriesSafe (key.first );
1388
- }
1389
- key.second .get ()->addValue (value);
1381
+ FOLLY_ERASE void add (int64_t value, Args&&... subkeys) {
1382
+ addImpl (value, cast (subkeys)...);
1390
1383
}
1391
1384
1392
1385
// "subkeys" must be a list of exactly N strings or integers, one for each
@@ -1445,6 +1438,25 @@ class DynamicTimeseriesWrapper {
1445
1438
}
1446
1439
1447
1440
private:
1441
+ FOLLY_ERASE static int64_t cast (int64_t subkey) {
1442
+ return subkey;
1443
+ }
1444
+ FOLLY_ERASE static std::string_view cast (std::string_view subkey) {
1445
+ return subkey;
1446
+ }
1447
+
1448
+ template <typename ... Args>
1449
+ void addImpl (int64_t value, Args... subkeys) {
1450
+ auto key = key_.getFormattedKeyWithExtra (subkeys...);
1451
+ if (key.second .get () == nullptr ) {
1452
+ ThreadCachedServiceData::ThreadLocalStatsMap& tcData =
1453
+ *ThreadCachedServiceData::getStatsThreadLocal ();
1454
+ // Cache thread local counter
1455
+ key.second .get () = tcData.getTimeseriesSafe (key.first );
1456
+ }
1457
+ key.second .get ()->addValue (value);
1458
+ }
1459
+
1448
1460
inline ThreadCachedServiceData::ThreadLocalStatsMap& tcData () {
1449
1461
return *ThreadCachedServiceData::getStatsThreadLocal ();
1450
1462
}
0 commit comments