On Wed, Mar 13, 2013 at 12:22:48AM +0000, Stephan Schiffels wrote:
> Am 12.03.13 20:22, schrieb Timon Gehr:
> >On 03/12/2013 06:51 PM, Stephan Schiffels wrote:
> >>...
> >>
> >>Thanks, I had a brief look at std.algorithm.joiner but couldn't find
> >>anything obvious, maybe I should look deeper into it.
> >>...
> >
> >I guess it is because of the following:
> >
> >Eg (similar code occurs two times):
> >...
> >     if (_sep.empty)
> >     {
> >         // Advance to the next range in the
> >         // input
> >         //_items.popFront();
> >         for (;; _items.popFront())
> >         {
> >             if (_items.empty) return;
> >             if (!_items.front.empty) break; // front called
> >         }
> >         _current = _items.front; // front called again
> >         _items.popFront();
> >     }
> >...
> >
> >The code should only call front once for the first non-empty range.
> >
> >Presumed example fix (though the implementation seems rather clumsy and
> >should probably be replaced completely):
> >
> >...
> >     if (_sep.empty)
> >     {
> >         // Advance to the next range in the
> >         // input
> >         //_items.popFront();
> >         for (;; _items.popFront())
> >         {
> >             if (_items.empty) return;
> >             _current = _items.front;
> >             if (!_current.empty) break;
> >         }
> >         _items.popFront();
> >     }
> >...
> 
> Thanks, that's very clear now. I stumbled over it because the
> function I call loads a lot of data and a factor 2 makes all the
> difference in runtime. Maybe I should file a bug report or at least
> a request to improve this.
[...]

I was the one responsible for the recent rewrite of joiner; I'll think
over how to fix it so that .front is only evaluated once.


T

-- 
Старый друг лучше новых двух.

Reply via email to