Faster UTF8 decode

This commit is contained in:
2024-11-14 20:58:04 +11:00
parent ff38a831f2
commit c7185fa370
2 changed files with 2 additions and 3 deletions

View File

@ -103,9 +103,8 @@ public struct ApkIndexUpdater {
print("Index time: \((ContinuousClock.now - indexStart).formatted(durFormat))")
}
let reader = TextInputStream(binaryStream: MemoryInputStream(buffer: apkIndexFile))
return try ApkIndex(raw:
try ApkRawIndex(lines: reader.lines))
try ApkRawIndex(lines: TextInputStream(binaryStream: MemoryInputStream(buffer: apkIndexFile)).lines))
}
}

View File

@ -74,7 +74,7 @@ struct TextInputStream<InStream: InputStream> where InStream.Element == UInt8 {
if _fastPath(!self._bytes.isEmpty) {
// Convert and return line
return String(bytes: self._bytes, encoding: .utf8)
return String(decoding: self._bytes, as: UTF8.self)
} else {
if _fastPath(!self._eof) {
// Don't bother decoding empty lines and just return an empty string