From 84197b1b98397c7c14c83c46a9330fac969616ef Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 21 Jan 2013 10:25:27 -0800 Subject: [PATCH] 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 --- src/conversions.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/conversions.cpp b/src/conversions.cpp index 0ded98381..fe916092d 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -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 -#if BOOST_VERSION < 104500 -#error you must have >= boost 104500 to use karma for string output -#endif - -#include -#include // log10 -#include // trunc to avoid needing C++11 + #include + #if BOOST_VERSION < 104500 + #undef MAPNIK_KARMA_TO_STRING + #else + #include + #include // log10 + #include // 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) {