Why the hell doesn't foreach decode strings

Steven Schveighoffer schveiguy at yahoo.com
Mon Oct 24 06:54:07 PDT 2011


On Fri, 21 Oct 2011 14:39:58 -0400, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 10/21/2011 4:14 AM, Steven Schveighoffer wrote:
>>> Making such a string type would be terribly inefficient. It would make  
>>> D
>>> completely uncompetitive for processing strings.
>>
>> I don't think it would. Do you have any proof to support this?
>
> I've done string processing code, and done a lot of profiling of them.  
> Every cycle is critical, and decoding adds a *lot* of cycles.

What I mean is, default to a well-built string type, and let people who  
want to deal with arrays of code-units deal with arrays of code-units.   
This schizophrenic view phobos has of char[] arrays as not being arrays is  
horrendous to work with.

For my usage, I almost never iterate over string characters or graphemes,  
I just pass strings.

-Steve


More information about the Digitalmars-d mailing list