remove use of std::to_string in favor of boost::lexical_cast

std::to_string calls sprintf() internally, which is really slow
This commit is contained in:
Konstantin Käfer
2014-12-04 12:59:09 +01:00
parent 65451187f5
commit b449b22abc
11 changed files with 45 additions and 29 deletions

View File

@@ -3,9 +3,27 @@
#include <string>
#pragma GCC diagnostic push
#ifndef __clang__
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
#include <boost/lexical_cast.hpp>
#pragma GCC diagnostic pop
namespace mbgl {
namespace util {
template <typename... Args>
inline std::string toString(Args&&... args) {
return boost::lexical_cast<std::string>(::std::forward<Args>(args)...);
}
// boost::lexical_cast() treats this as a character, but we are using it as number types.
inline std::string toString(int8_t num) {
return boost::lexical_cast<std::string>(int(num));
}
template<size_t max, typename... Args>
inline std::string sprintf(const char *msg, Args... args) {
char res[max];