Use std::to_string for non-mingw/cygwin
`std::to_string` is faster than `std::stringstream`.
This issue only presents in older versions of Mingw/Cygwin. My Mingw64 GCC 7.1.0 has `std::to_string`. I can't determine the exact version of GCC that fixed the issue.
Closes #4493.
PiperOrigin-RevId: 187145391
diff --git a/src/main/cpp/blaze_util.h b/src/main/cpp/blaze_util.h
index fa056b5..c28e55f 100644
--- a/src/main/cpp/blaze_util.h
+++ b/src/main/cpp/blaze_util.h
@@ -110,9 +110,13 @@
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015.
template <typename T>
std::string ToString(const T &value) {
+#if defined(__CYGWIN__) || defined(__MINGW32__)
std::ostringstream oss;
oss << value;
return oss.str();
+#else
+ return std::to_string(value);
+#endif
}
// Control the output of debug information by debug_log.