Q: Why does GCC implement std::to_string using std::vsnprintf? Recently, I looked into GCC's basic_string.h and noticed that all std::to_string overloads are implemented using std::vsnprintf like for example:
inline string
to_string(int __val)
{
    return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(int), "%d", __val);
}

Wouldn't this introduce a lot of overhead? Stringifying an integer base 10 is possible in just a few lines of code, so why would this be implemented using vsnprintf?

A: This looked good enough considering they had lots of other stuff to implement for C++ 11.
They optimized it recently with gcc 10 release.
