[D-runtime] foreach (dchar c; s) is too slow

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 2 01:47:14 PDT 2013


On Wednesday, October 02, 2013 07:29:07 Jacob Carlborg wrote:
> Can't we move some of the functionality to druntime? It doesn't need to be
> duplicated. Move what we can to druntime and publicly import that in
> Phobos.

That's not impossible, but it's not exactly straightforward either. Not only 
would it require duplicating a number of traits from std.traits and std.range, 
but the code in std.utf is actually written to operate on ranges of code units 
so that code that needs to operate at the code unit level can use them to 
iterate through and decode ranges of code units, whereas all druntime cares 
about is strings. IIRC, semi-recently monarch dodra ported the current std.utf 
stuff to druntime, but that involved altering it so that it was string-specific.

It's one of those cases where it would be nice to avoid code duplication but 
where druntime is missing stuff that it uses. It would be much easier if 
portions of std.traits and std.range were in druntime, but I'm not sure that 
we really want to do that. We do keep having to duplicate some of that stuff in 
druntime though, which is definitely annoying. So, I don't know what the best 
approach is. It will be very easy to start pulling in too much Phobos stuff 
into druntime if we're not careful.

- Jonathan M Davis


More information about the D-runtime mailing list