speed up snprintf double to string by removing unused code but default to using karma for now given it is more future proof - followup to #1697

This commit is contained in:
Dane Springmeyer 2013-01-21 10:25:27 -08:00
parent 27554cbef8
commit 84197b1b98

View file

@ -35,17 +35,19 @@
boost::spirit::domain_::domain, name##_expr_type); \
BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
//#define MAPNIK_KARMA_TO_STRING
// karma is used by default unless
// the boost version is too old
#define MAPNIK_KARMA_TO_STRING
#ifdef MAPNIK_KARMA_TO_STRING
#include <boost/version.hpp>
#if BOOST_VERSION < 104500
#error you must have >= boost 104500 to use karma for string output
#endif
#include <boost/spirit/include/karma.hpp>
#include <cmath> // log10
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
#include <boost/version.hpp>
#if BOOST_VERSION < 104500
#undef MAPNIK_KARMA_TO_STRING
#else
#include <boost/spirit/include/karma.hpp>
#include <cmath> // log10
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
#endif
#endif
namespace mapnik {
@ -342,16 +344,6 @@ bool to_string(std::string & s, bool val)
bool to_string(std::string & s, double val)
{
double abs_n = std::fabs(val);
std::string format;
if (abs_n >= 1e16 || abs_n < 1e-4)
{
format = "%e";
}
else
{
format = "%g";
}
s.resize(s.capacity());
while (true)
{