bitcoin/bitcoin — pull request #1567 by sipa (2012-07-07 21:12:34+00:00)
Title: CHashWriter that does SHA256 in-place during serialization

SerializeHash used to create a memory-backed CDataStream, serialize the object (almost always a CTransaction) to it, and then feed it to SHA256. As most of the time is actually spent in allocating/deallocating the buffer, it is better to do the SHA256 in-place. That is what CHashWriter does.

On my system, in ultraprune running on a tmpfs-backed datadir, this alone reduces total CPU time spent during import of 185k blocks by 4-5%.