Boost logo

Boost :

Subject: Re: [boost] [string_algo] first_finderF hoist empty check out of loop
From: Pavol Droba (droba_at_[hidden])
Date: 2010-04-04 15:38:18


Hi,

On 4. 4. 2010 21:35, Jeff Flinn wrote:
> In trying to get string algorithm icontains to work with spirit's
> file_iterator (which I still haven't been successful with) I noticed
> that the check for an empty search string is in side the loop. As:
>
> // Outer loop
> for(input_iterator_type OuterIt=Begin;
> OuterIt!=End;
> ++OuterIt)
> {
> // Sanity check
> if( boost::empty(m_Search) )
> return result_type( End, End );
>
> Wouldn't it be better to hoist this check out of the loop and only do it
> once?
>

Good point, makes sense.

Regards,
Pavol.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk