[Issue 8946] « any » function does not what it should do

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 3 18:12:28 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8946


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #9 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-11-03 18:12:26 PDT ---
> Then use canFind.

canFind does exactly the same thing.

The _only_ difference between calling find and checking whether the result was
empty rather than duplicating find's implementation inside of canFind or any is
the fact that a range is returned, and since that range is bound to be a
relatively small type (almost always either an array or a struct with just a
handful of member variables), the cost of that return is generally minimal, and
there's a halfway decent chance that a move was involved rather than a copy,
making it that much more efficient.

If there's a measurable difference in efficiency between calling find (and
checking for empty) and reimplementing find inside of canFind or any, then
maybe we'll look at making it so that canFind and any don't call find. But the
overhead of that return is so small (especially in comparison to the algorithm
itself), that I'd be surprised if that ever happened.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list