This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Is std::search coding fast enough?
- From: "Chris Jefferson" <chris at bubblescope dot net>
- To: "Dimitris Xochellis" <jimxoch at yahoo dot gr>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Wed, 4 Jul 2007 18:50:42 +0100
- Subject: Re: Is std::search coding fast enough?
- References: <473168.32327.qm@web23103.mail.ird.yahoo.com>
On 04/07/07, Dimitris Xochellis <jimxoch@yahoo.gr> wrote:
Hi list,
After reading the following std::search STL algorithm [1] I have got the impression that it can be
coded in a more efficient way. In my opinion, the code in the lines *A* & *C* guaranties that the
condition of the line *B* will be always true. Consequently, we can effectively replace the "while
(__first1 != __last1)" expression of the line *B* with a simpler "for ( ; ; )" expression and the
algorithm will work just fine and significantly faster as well.
I agree.
For a while I was worried that this code was wrong, I think the
"general case" wouldn't work for a search string of length 1, although
that doesn't matter as we special case that.
Chris