mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
Merge bitcoin/bitcoin#19690: util: improve FindByte() performance
72efc26439util: improve streams.h:FindByte() performance (Larry Ruane)604df63f6c[bench] add streams findbyte (gzhao408) Pull request description: This PR is strictly a performance improvement; there is no functional change. The `CBufferedFile::FindByte()` method searches for the next occurrence of the given byte in the file. Currently, this is done by explicitly inspecting each byte in turn. This PR takes advantage of `std::find()` to do the same more efficiently, improving its CPU runtime by a factor of about 25 in typical use. ACKs for top commit: achow101: re-ACK72efc26439stickies-v: re-ACK72efc26439Tree-SHA512: ddf0bff335cc8aa34f911aa4e0558fa77ce35d963d602e4ab1c63090b4a386faf074548daf06ee829c7f2c760d06eed0125cf4c34e981c6129cea1804eb3b719
This commit is contained in:
@@ -4565,7 +4565,7 @@ void Chainstate::LoadExternalBlockFile(
|
||||
try {
|
||||
// locate a header
|
||||
unsigned char buf[CMessageHeader::MESSAGE_START_SIZE];
|
||||
blkdat.FindByte(params.MessageStart()[0]);
|
||||
blkdat.FindByte(std::byte(params.MessageStart()[0]));
|
||||
nRewind = blkdat.GetPos() + 1;
|
||||
blkdat >> buf;
|
||||
if (memcmp(buf, params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE)) {
|
||||
|
||||
Reference in New Issue
Block a user