]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
basic_string.h (_S_find(const _CharT* __beg, const _CharT* __end, _CharT __c): Remove.
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 12 Jan 2001 21:24:15 +0000 (21:24 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 12 Jan 2001 21:24:15 +0000 (21:24 +0000)
2001-01-12  Benjamin Kosnik  <bkoz@redhat.com>

* include/bits/basic_string.h (_S_find(const _CharT* __beg, const
_CharT* __end, _CharT __c): Remove.
* include/bits/basic_string.tcc: Substitute traits::find for _S_find.
* include/bits/char_traits.h: Tweak.

From-SVN: r38961

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc
libstdc++-v3/include/bits/char_traits.h

index 859c72de7fe90469fce1d2dcb5c9be2dd47ee085..84efd3bf0bdd4d4645ad72c2850a34bbcce5c31b 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-12  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/bits/basic_string.h (_S_find(const _CharT* __beg, const
+       _CharT* __end, _CharT __c): Remove.
+       * include/bits/basic_string.tcc: Substitute traits::find for _S_find.
+       * include/bits/char_traits.h: Tweak.
+
 2001-01-12  Laurynas Biveinis  <lauras@softhome.net>
 
        * acinclude.m4 (GLIBCPP_CHECK_CTYPE_SUPPORT): check for DJGPP <ctype.h>
index 6f3b3726c03695fe4af78190163215bca3df6009..06b0820afbf00b26b5bfb835784b87cb6e6eb32f 100644 (file)
@@ -1,6 +1,6 @@
 // Components for manipulating sequences of characters -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -839,10 +839,6 @@ namespace std {
       int 
       compare(size_type __pos, size_type __n1, const _CharT* __s, 
              size_type __n2 = npos) const;
-    private:
-      static const _CharT* 
-      _S_find(const _CharT* __beg, const _CharT* __end, _CharT __c);
   };
 
 
index a9ac2c967817a16302cc05fb8eb83dd4fcefe199..27b0faddd8c736752c29e82cfad7f7b79100f38b 100644 (file)
@@ -574,23 +574,15 @@ namespace std
       return __n;
     }
 
-  // String operations
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    const _CharT*
-    basic_string<_CharT, _Traits, _Alloc>::
-    _S_find(const _CharT* __beg, const _CharT* __end, _CharT __c)
-    {
-      return find_if(__beg, __end, _Char_traits_match<_CharT, _Traits>(__c));
-    }
-
   template<typename _CharT, typename _Traits, typename _Alloc>
     basic_string<_CharT, _Traits, _Alloc>::size_type
     basic_string<_CharT, _Traits, _Alloc>::
     find(const _CharT* __s, size_type __pos, size_type __n) const
     {
+      size_type __size = this->size();
       size_t __xpos = __pos;
       const _CharT* __data = _M_data();
-      for (; __xpos + __n <= this->size(); ++__xpos)
+      for (; __xpos + __n <= __size; ++__xpos)
        if (traits_type::compare(__data + __xpos, __s, __n) == 0)
          return __xpos;
       return npos;
@@ -606,9 +598,9 @@ namespace std
       if (__pos < __size)
        {
          const _CharT* __data = _M_data();
-         const _CharT* __end = __data + __size;
-         const _CharT* __p = _S_find(__data + __pos, __end, __c);
-         if (__p != __end)
+         size_type __n = __size - __pos;
+         const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
+         if (__p)
            __ret = __p - __data;
        }
       return __ret;
@@ -659,11 +651,10 @@ namespace std
     basic_string<_CharT, _Traits, _Alloc>::
     find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
     {
-      const _CharT* __end = __s + __n;
       for (; __n && __pos < this->size(); ++__pos)
        {
-         const _CharT* __p = _S_find(__s, __end, _M_data()[__pos]);
-         if (__p != __end)
+         const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
+         if (__p)
            return __pos;
        }
       return npos;
@@ -681,8 +672,7 @@ namespace std
            __size = __pos;
          do
            {
-             const _CharT* __p = _S_find(__s, __s + __n, _M_data()[__size]);
-             if (__p  != __s + __n)
+             if (traits_type::find(__s, __n, _M_data()[__size]))
                return __size;
            } 
          while (__size-- != 0);
@@ -697,7 +687,7 @@ namespace std
     {
       size_t __xpos = __pos;
       for (; __n && __xpos < this->size(); ++__xpos)
-       if (_S_find(__s, __s + __n, _M_data()[__xpos]) == __s + __n)
+       if (!traits_type::find(__s, __n, _M_data()[__xpos]))
          return __xpos;
       return npos;
     }
@@ -708,7 +698,7 @@ namespace std
     find_first_not_of(_CharT __c, size_type __pos) const
     {
       size_t __xpos = __pos;
-      for (; __xpos < size(); ++__xpos)
+      for (; __xpos < this->size(); ++__xpos)
        if (!traits_type::eq(_M_data()[__xpos], __c))
          return __xpos;
       return npos;
@@ -726,7 +716,7 @@ namespace std
            __size = __pos;
          do
            {
-             if (_S_find(__s, __s + __n, _M_data()[__size]) == __s + __n)
+             if (!traits_type::find(__s, __n, _M_data()[__size]))
                return __size;
            } 
          while (__size--);
index baab72293c345405b098544d3f4cb12c8c043926..4d7833240ea57fddbff49741cb0ff85639fbfbd5 100644 (file)
@@ -1,6 +1,6 @@
 // Character Traits for use by standard string and iostream -*- C++ -*-
 
-// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -144,6 +144,7 @@ namespace std {
       { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
     };
 
+
   // 21.1.4  char_traits specializations
   template<>
     struct char_traits<char>
@@ -297,7 +298,7 @@ namespace std {
       _Char_traits_match(_CharT const& __c) : _M_c(__c) { }
 
       bool 
-      operator()(_CharT const& __a) { return _Traits::eq(_M_c,__a); }
+      operator()(_CharT const& __a) { return _Traits::eq(_M_c, __a); }
     };
 
 } // namespace std