"foreach(i, dchar c; s)" vs "decode"

Jonathan M Davis jmdavisProg at gmx.com
Mon Nov 26 20:54:59 PST 2012


On Monday, November 26, 2012 08:43:29 monarch_dodra wrote:
> Looking at 2.060 to 2.061, std.utf has changed a lot. I'll bench
> my algo using the old implementation of 2.060 to see if the
> change of performance could be related to that.

Some improvements were made to std.array.popFront for 2.060. I'm not sure that 
much in the way of changes to std.utf improved performance. I did most (all?) 
of them, but I don't remember all of the details now, so I'm not sure how many 
of them related to performance. Mostly what they did was make it so that 
stride, strideBack, and decode work with ranges of char and wchar, so that 
stuff like the D lexer can operate on ranges of code units rather than ranges 
of code points.

> As you said, I found how some a "rt.util.utf" module in druntime,
>   I was looking in the dmd tree. However, it is pretty much an old
> version of std.utf, verbatim...
> 
> Also, druntime has a *radically* different approach to striding
> UTF-8. I'll try to see which approach is faster.
> 
> I'd have suggested we try some sort of code sharing, but now that
> "std.utf" supports range, the code has "forked" and I'm not sure
> is shareable anymore... Not without duplicating code inside
> std.utf, or adding range support (or at least code) for decoding
> ranges in druntime.
> 
> Well, I'll see what I can uncover, and update dmd utf in the
> meantime...

Code sharing would be nice, but performance is far more critical in this case 
IMHO. The main question is how to speed up what druntime is doing. If that can 
be done while sharing code, then great. If not, then oh well.

- Jonathan M Davis


More information about the Digitalmars-d mailing list