Apply the same optimization to InetPathFormat.encodeSegment.

This commit is contained in:
Sönke Ludwig 2021-01-18 14:50:57 +01:00
parent 4bb5fc9ce8
commit dc0fe5ad73

View file

@ -1881,15 +1881,13 @@ struct InetPathFormat {
import std.array : appender; import std.array : appender;
foreach (i, char c; segment) { foreach (i, char c; segment) {
if (isAsciiAlphaNum(c)) continue;
switch (c) { switch (c) {
default: default:
auto ret = appender!string; auto ret = appender!string;
ret.put(segment[0 .. i]); ret.put(segment[0 .. i]);
encodeSegment(ret, segment[i .. $]); encodeSegment(ret, segment[i .. $]);
return ret.data; return ret.data;
case 'a': .. case 'z':
case 'A': .. case 'Z':
case '0': .. case '9':
case '-', '.', '_', '~': case '-', '.', '_', '~':
case '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': case '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=':
case ':', '@': case ':', '@':