diff --git a/flow/Trace.cpp b/flow/Trace.cpp index cca638f7ad..0872a502ae 100644 --- a/flow/Trace.cpp +++ b/flow/Trace.cpp @@ -1218,3 +1218,8 @@ void TraceEventFields::validateFormat() const { } } } + +std::string traceableStringToString(const char* value, size_t S) { + ASSERT_WE_THINK(value[S - 1] == '\0'); + return std::string(value, S - 1); // Exclude trailing \0 byte +} diff --git a/flow/Trace.h b/flow/Trace.h index b26699f6bd..69ee6175cf 100644 --- a/flow/Trace.h +++ b/flow/Trace.h @@ -262,6 +262,8 @@ struct TraceableString { } }; +std::string traceableStringToString(const char* value, size_t S); + template struct TraceableString { static const char* begin(const char* value) { @@ -272,9 +274,7 @@ struct TraceableString { return iter - value == S - 1; // Exclude trailing \0 byte } - static std::string toString(const char* value) { - return std::string(value, S - 1); // Exclude trailing \0 byte - } + static std::string toString(const char* value) { return traceableStringToString(value, S); } }; template<>