Add fast-path for filename String creation
In most cases, it's encoded with ASCI
This commit is contained in:
committed by
teamcityserver
parent
cd51264940
commit
920d57563b
@@ -97,7 +97,11 @@ fun MappedByteBuffer.parseCentralDirectory(): List<ZipEntryDescription> {
|
||||
position(currentOffset + 46)
|
||||
get(bytesForName)
|
||||
|
||||
val name = String(bytesForName)
|
||||
val name =
|
||||
if (bytesForName.all { it >= 0 })
|
||||
String(bytesForName.asASCICharArray())
|
||||
else
|
||||
String(bytesForName, Charsets.UTF_8)
|
||||
|
||||
currentOffset += 46 + fileNameLength + extraLength + fileCommentLength
|
||||
|
||||
@@ -120,4 +124,6 @@ fun MappedByteBuffer.parseCentralDirectory(): List<ZipEntryDescription> {
|
||||
return result
|
||||
}
|
||||
|
||||
private fun ByteArray.asASCICharArray(): CharArray = CharArray(size) { this@asASCICharArray[it].toChar() }
|
||||
|
||||
private fun ByteBuffer.getUnsignedShort(offset: Int): Int = java.lang.Short.toUnsignedInt(getShort(offset))
|
||||
|
||||
Reference in New Issue
Block a user