Avoid reallocating the data in readFileUTF8 if the UTF encoding is valid.
Uses the immutable overload of sanitizeUTF8 to reuse the original buffer if possible.
This commit is contained in:
parent
2e4bc6a316
commit
f56fd7580c
|
@ -118,7 +118,9 @@ string readFileUTF8(NativePath path)
|
||||||
{
|
{
|
||||||
import vibe.internal.string;
|
import vibe.internal.string;
|
||||||
|
|
||||||
return stripUTF8Bom(sanitizeUTF8(readFile(path)));
|
auto data = readFile(path);
|
||||||
|
auto idata = () @trusted { return data.assumeUnique; } ();
|
||||||
|
return stripUTF8Bom(sanitizeUTF8(idata));
|
||||||
}
|
}
|
||||||
/// ditto
|
/// ditto
|
||||||
string readFileUTF8(string path)
|
string readFileUTF8(string path)
|
||||||
|
|
Loading…
Reference in a new issue