mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-18 03:27:41 +02:00
refactor: Drop unused fclose() from BufferedFile
This was only explicitly used in the tests, where it can be replaced by wrapping the original raw file pointer into a CAutoFile on creation and then calling CAutoFile::fclose(). Also, it was used in LoadExternalBlockFile(), where it can also be replaced by the (implicit call to the) CAutoFile destructor after wrapping the original raw file pointer in a CAutoFile.
This commit is contained in:
@@ -4,19 +4,23 @@
|
||||
|
||||
#include <bench/bench.h>
|
||||
|
||||
#include <util/fs.h>
|
||||
#include <streams.h>
|
||||
#include <util/fs.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
static void FindByte(benchmark::Bench& bench)
|
||||
{
|
||||
// Setup
|
||||
FILE* file = fsbridge::fopen("streams_tmp", "w+b");
|
||||
CAutoFile file{fsbridge::fopen("streams_tmp", "w+b"), 0};
|
||||
const size_t file_size = 200;
|
||||
uint8_t data[file_size] = {0};
|
||||
data[file_size-1] = 1;
|
||||
fwrite(&data, sizeof(uint8_t), file_size, file);
|
||||
rewind(file);
|
||||
BufferedFile bf{file, /*nBufSize=*/file_size + 1, /*nRewindIn=*/file_size, 0};
|
||||
file << data;
|
||||
std::rewind(file.Get());
|
||||
BufferedFile bf{file.Get(), /*nBufSize=*/file_size + 1, /*nRewindIn=*/file_size, 0};
|
||||
|
||||
bench.run([&] {
|
||||
bf.SetPos(0);
|
||||
@@ -24,7 +28,7 @@ static void FindByte(benchmark::Bench& bench)
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
bf.fclose();
|
||||
file.fclose();
|
||||
fs::remove("streams_tmp");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user