C++ implementation: std::string::append is faster than std::stringstream