<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The runtime support for string foreach with decoding has some
serious performance issues.<br>
It's currently implemented by creating a delegate for the foreach
body and calling _aApply*.<br>
I recently submitted this pull to vibe.d
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<a href="https://github.com/rejectedsoftware/vibe.d/pull/327">https://github.com/rejectedsoftware/vibe.d/pull/327</a>.<br>
Using the explicit for (auto tmp = s; !tmp.empty; tmp.popFront()) {
auto c = tmp.front; /*CODE*/ }<br>
is about 3 times faster.<br>
I'd like to avoid such hidden performance pitfalls. Any ideas how to
transition to templated library code?<br>
For dchar iteration the compiler could simply prefer the range
interface, but that wouldn't work for wchar (or char with
w/dstrings).<br>
Is it something that should only be added to phobos, e.g. foreach
(c; s.byChar!dchar())?<br>
Or should this be a combination of compiler and library support,
i.e. when an explicit char type is given the compiler<br>
instantiates a template with that char type.<br>
</body>
</html>