https://issues.dlang.org/show_bug.cgi?id=11252

Jonathan M Davis <issues.dl...@jmdavisprog.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dl...@jmdavisprog.co
                   |                            |m

--- Comment #3 from Jonathan M Davis <issues.dl...@jmdavisprog.com> ---
in must be no worse than O(log n) or it is inappropriate to use it. And given
how iota works, that can't possibly be done in anything better than O(n) in the
general case, though it would be possible to implement it for integers
specifically. Honestly though, this seems like an abuse of the in operator to
me. in is really intended for lookup in containers. It's definitely not a range
operation.

A better alternative would be to add find/canFind as a member function to iota
in the cases where it would be more efficient than the std.algorithm
implementation. Then any code which uses find/canFind with UFCS with iota and
integral values would get a performance boost (including in generic code)
rather than just this specific case where the code is specifically written for
iota.

--

Reply via email to