| 74 | } |
| 75 | |
| 76 | std::string create(std::string_view counter_name, |
| 77 | label_pair* begin, label_pair* end) |
| 78 | { |
| 79 | // sort the input labels and remove duplicate keys |
| 80 | std::sort(begin, end, label_key_less); |
| 81 | end = std::unique(begin, end, label_key_equal); |
| 82 | |
| 83 | // calculate the total size and preallocate the buffer |
| 84 | auto size = std::accumulate(begin, end, |
| 85 | counter_name.size() + sizeof(DELIMITER), |
| 86 | [] (std::size_t sum, const label_pair& l) { |
| 87 | return sum + label_size(l); |
| 88 | }); |
| 89 | std::string result; |
| 90 | result.resize(size); |
| 91 | |
| 92 | // copy out the counter name and labels |
| 93 | auto out = result.begin(); |
| 94 | out = write(counter_name, out); |
| 95 | std::copy(begin, end, label_insert_iterator{out}); |
| 96 | |
| 97 | return result; |
| 98 | } |
| 99 | |
| 100 | std::string insert(const char* begin1, const char* end1, |
| 101 | label_pair* begin2, label_pair* end2) |
no test coverage detected