Skip to content

Commit 6c5f8a4

Browse files
committed
Added fast path for dchars in std.utf.byUTF
1 parent 014982c commit 6c5f8a4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

std/utf.d

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,8 +3609,16 @@ template byUTF(C) if (isSomeChar!C)
36093609
}
36103610
else
36113611
{
3612-
fill = cast(ushort)encode!(UseReplacementDchar.yes)(
3613-
buf, decodeFront!(UseReplacementDchar.yes)(r));
3612+
static if (is(RC == dchar))
3613+
{
3614+
fill = cast(ushort) encode!(UseReplacementDchar.yes)(buf, c);
3615+
r.popFront;
3616+
}
3617+
else
3618+
{
3619+
fill = cast(ushort) encode!(UseReplacementDchar.yes)(
3620+
buf, decodeFront!(UseReplacementDchar.yes)(r));
3621+
}
36143622
}
36153623
}
36163624
return buf[pos];

0 commit comments

Comments
 (0)