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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 3 14:35:37 PDT 2012


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



--- Comment #4 from Dimitri Sabadie <dimitri.sabadie at gmail.com> 2012-11-03 14:35:35 PDT ---
(In reply to comment #3)
> > Ok, my argument wasn’t worth it I agree. But, why any would use such a function
> where a simple loop and a test will do it?
> 
> Because find is a simple loop? To not duplicate code? If you have liner search
> then it's obvious (for me) to reuse it for exactly the same task. any basically
> gives you a bit less then find/countUntill (bool vs pointer-index) by doing the
> same amount of work.
> 
> > it consumes more memory that we want. any does things we don’t want to IMHO.
> 
> Simply not true. I'm not sure where this 'memory' argument comes from at all.
> In fact it saves some code space by not duplicating the same code over again.
> At best this could be an enhancement request (or better yet - a pull request)
> if there is a soild proof that the resulting code is measurably _faster_.

There’s a popFront() function, so why would it be the correct way to search?
Reusing a « linear search » code is not a point here because we want to _find_
something. countUntil gives us the position of an element, find should give
whether the element is or not in a range. It returns a range: why ? It’s
clearly implementation-related, and we don’t care about that detail. I’ll
propose a pull request because the simple fact there’s « find » and « any » is
not good.

-- 
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