Why the hell doesn't foreach decode strings

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Oct 22 13:42:05 PDT 2011


On 10/22/11 3:05 PM, Timon Gehr wrote:
> On 10/22/2011 09:37 PM, kennytm wrote:
>> Walter Bright<newshound2 at digitalmars.com> wrote:
>>> On 10/22/2011 2:21 AM, Peter Alexander wrote:
>>>> Which operations do you believe would be less efficient?
>>>
>>> All of the ones that don't require decoding, such as searching, would be
>>> less efficient if decoding was done.
>>
>> You can std.algorithm.find to do searching, not foreach. The former can
>> decide whichever efficient method to use.
>
> Afaics the current std.algorithm.find implementation decodes its arguments.

That can be easily fixed. Currently single-element find does decoding 
but substring find avoids it if possible:

https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L2819


Andrei


More information about the Digitalmars-d mailing list