Major performance problem with std.array.front()

Steven Schveighoffer schveiguy at yahoo.com
Fri Mar 7 05:40:33 PST 2014


On Thu, 06 Mar 2014 21:37:13 -0500, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> Is there any hope of fixing this?

Yes, make d strings not char arrays, but a library-defined struct with an  
array as backing.

auto x = "..."; compiles to => auto x =  
string(cast(immutable(char)[])"...");

Then define string to be whatever kind of range you want in the library,  
with whatever functionality you want.

Then if you want by-char traversal, explicitly use immutable(char)[] as  
x's type. And in the string range's members, we can provide whatever  
access we want.

Note, this also fixes foreach, and many other problems we have. Most  
likely code that works today will continue to work, since it's much more  
of a bear to type immutable(char)[] instead of string :)

-Steve


More information about the Digitalmars-d mailing list