OpenEmu/OpenEmu — pull request #1134 by joewreschnig (2014-02-02 22:38:32+00:00)
Title: Avoid per-byte ObjC message when importing (~20% faster)

This commit reduced import times of large files (500MB+) by about 20% for me. It will be less useful on spinning drives, but won't hurt, and it's a pretty straightforward optimization.

I also tried switching the NSFileHandle to an NSInputStream and reusing the same buffer rather than allocating a new NSData each time, but it was much more complicated code for a barely-measurable effect (< 5% improvement even for very large files), so I didn't do it.
--
Rename md5ChunkSize to HASH_READ_CHUNK_SIZE and remove the unused crc32ChunkSize as the same read chunk is used for both hashes. Increase the chunk size from 10KB to 32KB. Optimize CRC32 inner loop to avoid calling the length message for each byte. Together these changes reduce total hash calculation time by about 20% when reading from an SSD.