mirror of
				https://github.com/GayPizzaSpecifications/darwin-apk.git
				synced 2025-11-03 23:49:38 +00:00 
			
		
		
		
	Faster UTF8 decode
This commit is contained in:
		@ -103,9 +103,8 @@ public struct ApkIndexUpdater {
 | 
				
			|||||||
      print("Index time: \((ContinuousClock.now - indexStart).formatted(durFormat))")
 | 
					      print("Index time: \((ContinuousClock.now - indexStart).formatted(durFormat))")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let reader = TextInputStream(binaryStream: MemoryInputStream(buffer: apkIndexFile))
 | 
					 | 
				
			||||||
    return try ApkIndex(raw:
 | 
					    return try ApkIndex(raw:
 | 
				
			||||||
      try ApkRawIndex(lines: reader.lines))
 | 
					      try ApkRawIndex(lines: TextInputStream(binaryStream: MemoryInputStream(buffer: apkIndexFile)).lines))
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -74,7 +74,7 @@ struct TextInputStream<InStream: InputStream> where InStream.Element == UInt8 {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if _fastPath(!self._bytes.isEmpty) {
 | 
					        if _fastPath(!self._bytes.isEmpty) {
 | 
				
			||||||
          // Convert and return line
 | 
					          // Convert and return line
 | 
				
			||||||
          return String(bytes: self._bytes, encoding: .utf8)
 | 
					          return String(decoding: self._bytes, as: UTF8.self)
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          if _fastPath(!self._eof) {
 | 
					          if _fastPath(!self._eof) {
 | 
				
			||||||
            // Don't bother decoding empty lines and just return an empty string
 | 
					            // Don't bother decoding empty lines and just return an empty string
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user