From 1b3ef49377084eb346a84a59c8344e977ee1e47b Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 16 Jan 2013 10:51:45 +0000 Subject: [PATCH] + remove unnecessarily checks --- src/conversions.cpp | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/src/conversions.cpp b/src/conversions.cpp index af9ac36af..34666c77b 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -82,11 +82,8 @@ struct bool_symbols : qi::symbols bool string2bool(const char * value, bool & result) { using boost::spirit::qi::no_case; - size_t length = std::strlen(value); - if (length < 1 || value == NULL) - return false; - const char *iter = value; - const char *end = value + length; + const char *iter = value; + const char *end = value + std::strlen(value); bool r = qi::phrase_parse(iter,end, no_case[bool_symbols()] ,ascii::space,result); return r && (iter == end); } @@ -94,8 +91,6 @@ bool string2bool(const char * value, bool & result) bool string2bool(std::string const& value, bool & result) { using boost::spirit::qi::no_case; - if (value.empty()) - return false; std::string::const_iterator str_beg = value.begin(); std::string::const_iterator str_end = value.end(); bool r = qi::phrase_parse(str_beg,str_end,no_case[bool_symbols()],ascii::space,result); @@ -104,19 +99,14 @@ bool string2bool(std::string const& value, bool & result) bool string2int(const char * value, int & result) { - size_t length = std::strlen(value); - if (length < 1 || value == NULL) - return false; const char *iter = value; - const char *end = value + length; + const char *end = value + std::strlen(value); bool r = qi::phrase_parse(iter,end,INTEGER,ascii::space,result); return r && (iter == end); } bool string2int(std::string const& value, int & result) { - if (value.empty()) - return false; std::string::const_iterator str_beg = value.begin(); std::string::const_iterator str_end = value.end(); bool r = qi::phrase_parse(str_beg,str_end,INTEGER,ascii::space,result); @@ -126,19 +116,14 @@ bool string2int(std::string const& value, int & result) #ifdef BIGINT bool string2int(const char * value, mapnik::value_integer & result) { - size_t length = std::strlen(value); - if (length < 1 || value == NULL) - return false; const char *iter = value; - const char *end = value + length; + const char *end = value + std::strlen(value); bool r = qi::phrase_parse(iter,end,LONGLONG,ascii::space,result); return r && (iter == end); } bool string2int(std::string const& value, mapnik::value_integer & result) { - if (value.empty()) - return false; std::string::const_iterator str_beg = value.begin(); std::string::const_iterator str_end = value.end(); bool r = qi::phrase_parse(str_beg,str_end,LONGLONG,ascii::space,result); @@ -148,8 +133,6 @@ bool string2int(std::string const& value, mapnik::value_integer & result) bool string2double(std::string const& value, double & result) { - if (value.empty()) - return false; std::string::const_iterator str_beg = value.begin(); std::string::const_iterator str_end = value.end(); bool r = qi::phrase_parse(str_beg,str_end,DOUBLE,ascii::space,result); @@ -158,19 +141,14 @@ bool string2double(std::string const& value, double & result) bool string2double(const char * value, double & result) { - size_t length = std::strlen(value); - if (length < 1 || value == NULL) - return false; - const char *iter = value; - const char *end = value + length; + const char *iter = value; + const char *end = value + std::strlen(value); bool r = qi::phrase_parse(iter,end,DOUBLE,ascii::space,result); return r && (iter == end); } bool string2float(std::string const& value, float & result) { - if (value.empty()) - return false; std::string::const_iterator str_beg = value.begin(); std::string::const_iterator str_end = value.end(); bool r = qi::phrase_parse(str_beg,str_end,FLOAT,ascii::space,result); @@ -179,16 +157,12 @@ bool string2float(std::string const& value, float & result) bool string2float(const char * value, float & result) { - size_t length = std::strlen(value); - if (length < 1 || value == NULL) - return false; const char *iter = value; - const char *end = value + length; + const char *end = value + std::strlen(value); bool r = qi::phrase_parse(iter,end,FLOAT,ascii::space,result); return r && (iter == end); } - #if BOOST_VERSION >= 104500 bool to_string(std::string & str, int value)