Skip to content

Commit 233f3d2

Browse files
committed
Replace the use of detail::TrimString with common::Trim
1 parent 4e54a63 commit 233f3d2

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

api/include/opentelemetry/trace/propagation/detail/string.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,6 @@ inline size_t SplitString(nostd::string_view s,
5656

5757
return filled;
5858
}
59-
60-
inline nostd::string_view TrimString(nostd::string_view s)
61-
{
62-
size_t str_size = s.size();
63-
size_t trimmed_str_start_pos = 0;
64-
size_t trimmed_str_end_pos = 0;
65-
bool start_pos_found = false;
66-
for (size_t i = 0; i < str_size; i++)
67-
{
68-
if (!isspace(s[i]))
69-
{
70-
if (!start_pos_found)
71-
{
72-
trimmed_str_start_pos = i;
73-
trimmed_str_end_pos = i;
74-
start_pos_found = true;
75-
} else
76-
{
77-
trimmed_str_end_pos = i;
78-
}
79-
}
80-
}
81-
return s.substr(trimmed_str_start_pos, trimmed_str_end_pos - trimmed_str_start_pos + 1);
82-
}
83-
8459
} // namespace detail
8560
} // namespace propagation
8661
} // namespace trace

api/include/opentelemetry/trace/propagation/http_trace_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class HttpTraceContext : public context::propagation::TextMapPropagator
183183
static SpanContext ExtractImpl(const context::propagation::TextMapCarrier &carrier)
184184
{
185185
// Get trace_parent after trimming the leading and trailing whitespaces
186-
nostd::string_view trace_parent = detail::TrimString(carrier.Get(kTraceParent));
186+
nostd::string_view trace_parent = common::StringUtil::Trim(carrier.Get(kTraceParent));
187187
nostd::string_view trace_state = carrier.Get(kTraceState);
188188
if (trace_parent == "")
189189
{

api/test/trace/propagation/detail/string_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "opentelemetry/nostd/string_view.h"
99

10-
TEST(StringTest, TrimStrings)
10+
TEST(StringTest, SplitString)
1111
{
1212
//TODO(psx95): Add tests
1313
}

0 commit comments

Comments
 (0)