Skip to content

Commit

Permalink
use appender instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
JackStouffer committed Sep 17, 2016
1 parent 65c4648 commit 2f24a0a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions std/utf.d
Original file line number Diff line number Diff line change
Expand Up @@ -2470,8 +2470,15 @@ char[] toUTF8(return out char[4] buf, dchar c) nothrow @nogc @safe pure
*/
string toUTF8(S)(S s) if (isSomeString!S)
{
import std.array : array;
return s.byChar.array;
import std.array : appender;

auto app = appender!string();
app.reserve(s.length);

foreach (c; s.byChar)
app.put(c);

return app.data;
}

///
Expand Down

0 comments on commit 2f24a0a

Please sign in to comment.