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:
parent
27554cbef8
commit
84197b1b98
1 changed files with 11 additions and 19 deletions
|
@ -35,18 +35,20 @@
|
|||
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
|
||||
|
||||
#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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue