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

monarch_dodra monarchdodra at gmail.com
Tue Nov 27 05:41:14 PST 2012


On Monday, 26 November 2012 at 07:43:30 UTC, monarch_dodra wrote:
> Also, druntime has a *radically* different approach to striding 
> UTF-8. I'll try to see which approach is faster.

Well, my (quick) benches showed that unless the input is 
something like 90% multibyte unicode, std.utf's stride 
implementation beats the crap out of rc.util.utf's.

Depending on compile options (-inline/-noboundscheck):

Given an ASCII string, then phobo's implementation is anywhere 
from 100% to 500% faster.

Given a unicode only string, then UTF's is actually 30% faster.

If anybody else wants to have a go at it...

I'll go ahead and update rc.util.utf's implementation to match 
phobo's (minus @jmdavis' support for ranges).


More information about the Digitalmars-d mailing list