Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-04-29 08:22:23


Author: drrngrvy
Date: 2008-04-29 08:22:22 EDT (Tue, 29 Apr 2008)
New Revision: 44879
URL: http://svn.boost.org/trac/boost/changeset/44879

Log:
Fix ichar_traits<>::compare(). Minor optimisations to ichar_traits<>::find() and save_environment().
Text files modified:
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp | 18 +++++++++++-------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp | 7 +++++--
   2 files changed, 16 insertions(+), 9 deletions(-)

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/name.hpp 2008-04-29 08:22:22 EDT (Tue, 29 Apr 2008)
@@ -37,20 +37,24 @@
                        , const char* str2
                        , std::size_t num )
      {
- if ( !(std::toupper(*str1) - std::toupper(*str2)) )
- return 0;
+ if (num)
+ do {
+ if (std::toupper(*str1) != std::toupper(*str2))
+ return (std::toupper(*str1) - std::toupper(*str2));
+ ++str1;
+ ++str2;
+ } while (--num);
 
- int d = 0;
- while (--num && !(d = std::toupper(*++str1) - std::toupper(*++str2)))
- ;
- return d;
+ return 0;
      }
 
      static const char*
        find(const char* str, int n, char a)
      {
- while( n-- > 0 && std::toupper(*str) != std::toupper(a) )
+ do {
+ std::toupper(*str) != std::toupper(a);
          ++str;
+ } while (--n);
        return str;
      }
 

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/detail/save_environment.hpp 2008-04-29 08:22:22 EDT (Tue, 29 Apr 2008)
@@ -34,6 +34,9 @@
    template<typename MapT>
    void save_environment(MapT& env_map, char** env = environ)
    {
+ std::string sa;
+ std::string sb;
+
      for(; *env; ++env)
      {
        int i=0;
@@ -46,8 +49,8 @@
        // we are free to ignore them too.
        if ((*env)[i+1] != '\0')
        {
- std::string sa(*env, i);
- std::string sb((*env+i+1), j-i-1);
+ sa.assign(*env, i);
+ sb.assign((*env+i+1), j-i-1);
          env_map[sa.c_str()] = sb;
        }
      }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk