Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / base / String.cc
index be0bb64..fb7bd35 100644 (file)
@@ -173,15 +173,11 @@ namespace zypp
      **      FUNCTION TYPE : std::string
     */
     std::string toLower( const std::string & s )
-    { return toLower( std::string(s) ); }
-
-    std::string toLower( std::string && s )
     {
-      std::string ret( std::move(s) );
-
-      if ( ret.empty() )
-        return ret;
+      if ( s.empty() )
+        return s;
 
+      std::string ret( s );
       for ( std::string::size_type i = 0; i < ret.length(); ++i )
         {
           if ( isupper( ret[i] ) )
@@ -196,15 +192,11 @@ namespace zypp
      **      FUNCTION TYPE : std::string
     */
     std::string toUpper( const std::string & s )
-    { return toUpper( std::string(s) ); }
-
-    std::string toUpper( std::string && s )
     {
-      std::string ret( std::move(s) );
-
-      if ( ret.empty() )
-        return ret;
+      if ( s.empty() )
+        return s;
 
+      std::string ret( s );
       for ( std::string::size_type i = 0; i < ret.length(); ++i )
         {
           if ( islower( ret[i] ) )
@@ -219,36 +211,29 @@ namespace zypp
      **      FUNCTION TYPE : std::string
     */
     std::string trim( const std::string & s, const Trim trim_r )
-    { return trim( std::string(s), trim_r ); }
-
-    std::string trim( std::string && s, const Trim trim_r )
     {
-      std::string ret( std::move(s) );
+      if ( s.empty() || trim_r == NO_TRIM )
+        return s;
 
-      if ( ret.empty() || trim_r == NO_TRIM )
-        return ret;
+      std::string ret( s );
 
       if ( trim_r & L_TRIM )
-      {
-       std::string::size_type p = ret.find_first_not_of( " \t\n" );
-       if ( p == std::string::npos )
-       {
-         ret.clear();
-         return ret;
-       }
-       ret.erase( 0, p );
-      }
+        {
+          std::string::size_type p = ret.find_first_not_of( " \t\n" );
+          if ( p == std::string::npos )
+            return std::string();
+
+          ret = ret.substr( p );
+        }
 
       if ( trim_r & R_TRIM )
-      {
-       std::string::size_type p = ret.find_last_not_of( " \t\n" );
-       if ( p == std::string::npos )
-       {
-         ret.clear();
-         return ret;
-       }
-       ret = ret.erase( p+1 );
-      }
+        {
+          std::string::size_type p = ret.find_last_not_of( " \t\n" );
+          if ( p == std::string::npos )
+            return std::string();
+
+          ret = ret.substr( 0, p+1 );
+        }
 
       return ret;
     }