use the std library tolower over boost::algorithm::to_lower for both better runtime and compile speed - closes #1677

This commit is contained in:
Dane Springmeyer 2013-01-03 19:27:53 -08:00
parent c61335c277
commit e682705a86
5 changed files with 21 additions and 12 deletions

View file

@ -24,9 +24,8 @@
// std // std
#include <istream> #include <istream>
#include <algorithm>
// boost #include <string>
#include <boost/algorithm/string.hpp>
namespace mapnik namespace mapnik
{ {
@ -65,7 +64,7 @@ operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
{ {
std::string word; std::string word;
s >> word; s >> word;
boost::algorithm::to_lower(word); std::transform(word.begin(), word.end(), word.begin(), ::tolower);
if ( s ) if ( s )
{ {
if ( word == "true" || word == "yes" || word == "on" || if ( word == "true" || word == "yes" || word == "on" ||

View file

@ -30,6 +30,7 @@
// mapnik // mapnik
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/feature_layer_desc.hpp> #include <mapnik/feature_layer_desc.hpp>
#include <mapnik/feature_factory.hpp> #include <mapnik/feature_factory.hpp>
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
@ -47,6 +48,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <string> #include <string>
#include <algorithm>
using mapnik::datasource; using mapnik::datasource;
using mapnik::parameters; using mapnik::parameters;
@ -267,7 +269,8 @@ void csv_datasource::parse_csv(T & stream,
for (; beg != tok.end(); ++beg) for (; beg != tok.end(); ++beg)
{ {
std::string val = mapnik::util::trim_copy(*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" if (lower_val == "wkt"
|| (lower_val.find("geom") != std::string::npos)) || (lower_val.find("geom") != std::string::npos))
{ {
@ -345,7 +348,8 @@ void csv_datasource::parse_csv(T & stream,
} }
else 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" if (lower_val == "wkt"
|| (lower_val.find("geom") != std::string::npos)) || (lower_val.find("geom") != std::string::npos))
{ {

View file

@ -26,6 +26,7 @@
// stl // stl
#include <string> #include <string>
#include <vector> #include <vector>
#include <algorithm>
// mapnik // mapnik
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
@ -642,7 +643,7 @@ public:
const char* fld_name = rs->column_text(1); const char* fld_name = rs->column_text(1);
std::string fld_type(rs->column_text(2)); std::string fld_type(rs->column_text(2));
sqlite_int64 fld_pk = rs->column_integer64(5); 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 ? // TODO - how to handle primary keys on multiple columns ?
if (key_field.empty() && ! found_pk && fld_pk != 0) if (key_field.empty() && ! found_pk && fld_pk != 0)

View file

@ -32,7 +32,10 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
// stl
#include <sstream> #include <sstream>
#include <algorithm>
// icu // icu
#include <unicode/ubidi.h> #include <unicode/ubidi.h>
@ -59,7 +62,8 @@ freetype_engine::~freetype_engine()
bool freetype_engine::is_font_file(std::string const& file_name) bool freetype_engine::is_font_file(std::string const& file_name)
{ {
/** only accept files that will be matched by freetype2's `figurefiletype()` */ /** 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")) || return boost::algorithm::ends_with(fn,std::string(".ttf")) ||
boost::algorithm::ends_with(fn,std::string(".otf")) || boost::algorithm::ends_with(fn,std::string(".otf")) ||
boost::algorithm::ends_with(fn,std::string(".ttc")) || boost::algorithm::ends_with(fn,std::string(".ttc")) ||

View file

@ -55,6 +55,7 @@ extern "C"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <algorithm>
namespace mapnik namespace mapnik
{ {
@ -225,8 +226,8 @@ void save_to_stream(T const& image,
{ {
if (stream && image.width() > 0 && image.height() > 0) if (stream && image.width() > 0 && image.height() > 0)
{ {
//all this should go into image_writer factory std::string t = type;
std::string t = boost::algorithm::to_lower_copy(type); std::transform(t.begin(), t.end(), t.begin(), ::tolower);
if (t == "png" || boost::algorithm::starts_with(t, "png")) if (t == "png" || boost::algorithm::starts_with(t, "png"))
{ {
int colors = 256; int colors = 256;
@ -286,8 +287,8 @@ void save_to_stream(T const& image,
{ {
if (stream && image.width() > 0 && image.height() > 0) if (stream && image.width() > 0 && image.height() > 0)
{ {
//all this should go into image_writer factory std::string t = type;
std::string t = boost::algorithm::to_lower_copy(type); std::transform(t.begin(), t.end(), t.begin(), ::tolower);
if (t == "png" || boost::algorithm::starts_with(t, "png")) if (t == "png" || boost::algorithm::starts_with(t, "png"))
{ {
int colors = 256; int colors = 256;