libstdc++/1066: bad use of strchr() in std::string

Nathan Myers ncm@best.com
Fri Dec 22 15:29:00 GMT 2000


What's wrong with just

   return std::find(__beg, __end, __c);
  
?  The C library components are inherently less efficient, and
more complicated too.

Nathan Myers
ncm at cantrip dot org

On Fri, Dec 22, 2000 at 06:28:09AM -0500, Brad Garcia wrote:
> 
> Yep, that looks good to me.
> 
> On Thu, 21 Dec 2000, Benjamin Kosnik wrote:
> 
> > 
> > http://gcc.gnu.org/ml/gcc-bugs/2000-12/msg00357.html
> > 
> > can't 
> > 
> > #if _GLIBCPP_INSTANTIATING_CHAR
> >   template<>
> >     const char* 
> >     string::_S_find(const char* __beg, const char* __end, char __c)
> >     { 
> >       char* __retval = strchr(__beg, __c); 
> >       return (__retval ? __retval : __end);
> >     }
> > #else
> > 
> > just be replaced with
> > 
> > #if _GLIBCPP_INSTANTIATING_CHAR
> >   template<>
> >     const char* 
> >     string::_S_find(const char* __beg, const char* __end, char __c)
> >     { 
> >       char* __retval = memchr(__beg, __c, __end - __beg); 
> >       return (__retval ? __retval : __end);
> >     }
> > #else
> > 
> 
> Brad Garcia


More information about the Libstdc++ mailing list