Why the hell doesn't foreach decode strings

Timon Gehr timon.gehr at gmx.ch
Sat Oct 22 15:32:20 PDT 2011


On 10/22/2011 10:42 PM, Andrei Alexandrescu wrote:
> 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
>

Ok, I actually did not see that, thanks. However this is usually still 
not the most efficient implementation in case the first argument is 
string and the other is wstring/dstring.


More information about the Digitalmars-d mailing list