What features of D are you using now which you thought you'd never goint to use?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jun 25 15:38:45 PDT 2013
On Wednesday, June 26, 2013 00:11:29 Timon Gehr wrote:
> On 06/25/2013 10:37 PM, Jonathan M Davis wrote:
> > On Tuesday, June 25, 2013 21:42:17 Timon Gehr wrote:
> >> Take will check the wrapped range's 'empty' repeatedly. takeExactly does
> >> not need to do that at all.
> >
> > It only does that with assertions. ...
>
> https://github.com/D-Programming-Language/phobos/blob/master/std/range.d#L26
> 48
Clearly, I missed that. Well, it is true that takeExactly avoids calling empty
on the range that it's wrapping in its own empty function, but it's pretty
rare that a wrapper range doesn't call the wrapped empty in its own empty
function. So, I'd tend to view that as on optimization on takeExactly's part
rather than a deficiency on take's part.
Regardless, it's definitely more efficient to use takeExactly when you can. The
_only_ benefit to take over takeExactly (assuming that the propagation issue is
fixed) is that you don't have to guarantee that the range you're passing it has
enough elements. If you know that it does, then takeExactly is better.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list