From e682705a86727a2e8769bb576754c65d37a88116 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 3 Jan 2013 19:27:53 -0800 Subject: [PATCH] use the std library tolower over boost::algorithm::to_lower for both better runtime and compile speed - closes #1677 --- include/mapnik/boolean.hpp | 7 +++---- plugins/input/csv/csv_datasource.cpp | 8 ++++++-- plugins/input/sqlite/sqlite_utils.hpp | 3 ++- src/font_engine_freetype.cpp | 6 +++++- src/image_util.cpp | 9 +++++---- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/mapnik/boolean.hpp b/include/mapnik/boolean.hpp index bc9b46cc4..8d7520bad 100644 --- a/include/mapnik/boolean.hpp +++ b/include/mapnik/boolean.hpp @@ -24,9 +24,8 @@ // std #include - -// boost -#include +#include +#include namespace mapnik { @@ -65,7 +64,7 @@ operator >> ( std::basic_istream & s, boolean & b ) { std::string word; s >> word; - boost::algorithm::to_lower(word); + std::transform(word.begin(), word.end(), word.begin(), ::tolower); if ( s ) { if ( word == "true" || word == "yes" || word == "on" || diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 7ec0c24c0..e23b19d74 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -30,6 +30,7 @@ // mapnik #include +#include #include #include #include @@ -47,6 +48,7 @@ #include #include #include +#include using mapnik::datasource; using mapnik::parameters; @@ -267,7 +269,8 @@ void csv_datasource::parse_csv(T & stream, for (; beg != tok.end(); ++beg) { std::string val = mapnik::util::trim_copy(*beg); - std::string lower_val = boost::algorithm::to_lower_copy(val); + std::string lower_val = val; + std::transform(lower_val.begin(), lower_val.end(), lower_val.begin(), ::tolower); if (lower_val == "wkt" || (lower_val.find("geom") != std::string::npos)) { @@ -345,7 +348,8 @@ void csv_datasource::parse_csv(T & stream, } else { - std::string lower_val = boost::algorithm::to_lower_copy(val); + std::string lower_val = val; + std::transform(lower_val.begin(), lower_val.end(), lower_val.begin(), ::tolower); if (lower_val == "wkt" || (lower_val.find("geom") != std::string::npos)) { diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index a7699ecaa..5463dac2c 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -26,6 +26,7 @@ // stl #include #include +#include // mapnik #include @@ -642,7 +643,7 @@ public: const char* fld_name = rs->column_text(1); std::string fld_type(rs->column_text(2)); sqlite_int64 fld_pk = rs->column_integer64(5); - boost::algorithm::to_lower(fld_type); + std::transform(fld_type.begin(), fld_type.end(), fld_type.begin(), ::tolower); // TODO - how to handle primary keys on multiple columns ? if (key_field.empty() && ! found_pk && fld_pk != 0) diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 60f3e64af..6def8cba7 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -32,7 +32,10 @@ #include #include #include + +// stl #include +#include // icu #include @@ -59,7 +62,8 @@ freetype_engine::~freetype_engine() bool freetype_engine::is_font_file(std::string const& file_name) { /** only accept files that will be matched by freetype2's `figurefiletype()` */ - std::string const& fn = boost::algorithm::to_lower_copy(file_name); + std::string fn = file_name; + std::transform(fn.begin(), fn.end(), fn.begin(), ::tolower); return boost::algorithm::ends_with(fn,std::string(".ttf")) || boost::algorithm::ends_with(fn,std::string(".otf")) || boost::algorithm::ends_with(fn,std::string(".ttc")) || diff --git a/src/image_util.cpp b/src/image_util.cpp index 2cf22d186..6b3c87df1 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -55,6 +55,7 @@ extern "C" #include #include #include +#include namespace mapnik { @@ -225,8 +226,8 @@ void save_to_stream(T const& image, { if (stream && image.width() > 0 && image.height() > 0) { - //all this should go into image_writer factory - std::string t = boost::algorithm::to_lower_copy(type); + std::string t = type; + std::transform(t.begin(), t.end(), t.begin(), ::tolower); if (t == "png" || boost::algorithm::starts_with(t, "png")) { int colors = 256; @@ -286,8 +287,8 @@ void save_to_stream(T const& image, { if (stream && image.width() > 0 && image.height() > 0) { - //all this should go into image_writer factory - std::string t = boost::algorithm::to_lower_copy(type); + std::string t = type; + std::transform(t.begin(), t.end(), t.begin(), ::tolower); if (t == "png" || boost::algorithm::starts_with(t, "png")) { int colors = 256;