protocol for using InputRanges

monarch_dodra monarchdodra at gmail.com
Wed Mar 26 09:38:57 PDT 2014


On Wednesday, 26 March 2014 at 15:37:38 UTC, Steven Schveighoffer 
wrote:
> Yes, but when you know that empty is going to return false, 
> there isn't any logical reason to call it. It is an awkward 
> requirement.
>
> -Steve

Not only that, but it's also a performance criteria: If you are 
iterating on two ranges at once (think "copy"), then you *know* 
"range2" is longer than "range1", even if you don't know its 
length.

Why pay for "range2.empty", when you know it'll always be false? 
There is a noticeable performance difference if you *don't* check.


More information about the Digitalmars-d mailing list