11#include < datadog/baggage.h>
22
3- #include < cctype>
4-
53namespace datadog {
64namespace tracing {
75
@@ -30,7 +28,7 @@ parse_baggage(StringView input, size_t max_capacity) {
3028 for (size_t i = 0 ; i < end; ++i) {
3129 switch (internal_state) {
3230 case state::leading_spaces_key: {
33- if (! std::isspace ( input[i]) ) {
31+ if (input[i] != ' ' ) {
3432 if (result.size () == max_capacity)
3533 return Baggage::Error::MAXIMUM_CAPACITY_REACHED;
3634
@@ -46,13 +44,13 @@ parse_baggage(StringView input, size_t max_capacity) {
4644 } else if (input[i] == ' =' ) {
4745 key = StringView{input.data () + beg, tmp_end - beg + 1 };
4846 internal_state = state::leading_spaces_value;
49- } else if (! std::isspace ( input[i]) ) {
47+ } else if (input[i] != ' ' ) {
5048 tmp_end = i;
5149 }
5250 } break ;
5351
5452 case state::leading_spaces_value: {
55- if (! std::isspace ( input[i]) ) {
53+ if (input[i] != ' ' ) {
5654 beg = i;
5755 tmp_end = i;
5856 internal_state = state::value;
@@ -66,7 +64,7 @@ parse_baggage(StringView input, size_t max_capacity) {
6664 beg = i;
6765 tmp_end = i;
6866 internal_state = state::leading_spaces_key;
69- } else if (! std::isspace ( input[i]) ) {
67+ } else if (input[i] != ' ' ) {
7068 tmp_end = i;
7169 }
7270 } break ;
@@ -165,6 +163,7 @@ Expected<Baggage, Baggage::Error> Baggage::extract(const DictReader& headers,
165163 return Error::MISSING_HEADER;
166164 }
167165
166+ // TODO(@dmehala): Avoid allocation
168167 auto bv = parse_baggage (*found, max_capacity);
169168 if (auto error = bv.if_error ()) {
170169 return *error;
0 commit comments