Skip to content

Commit

Permalink
Use C++11 style instead of C++20
Browse files Browse the repository at this point in the history
  • Loading branch information
danilak-G committed Apr 4, 2024
1 parent a60fd60 commit 4e693db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions snappy_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace {

void FilesAndLevels(::testing::Benchmark* benchmark) {
for (int i = 0; i < ARRAYSIZE(kTestDataFiles); ++i) {
for (int level = snappy::CompressionOptions::MinCompressionLevel();
for (int/*level=*/snappy::CompressionOptions::MinCompressionLevel();
level <= snappy::CompressionOptions::MaxCompressionLevel(); ++level) {
benchmark->ArgPair(i, level);
}
Expand All @@ -65,7 +65,7 @@ void BM_UFlat(benchmark::State& state) {

std::string zcontents;
snappy::Compress(contents.data(), contents.size(), &zcontents,
snappy::CompressionOptions{.level = state.range(1)});
snappy::CompressionOptions{/*level=*/state.range(1)});
char* dst = new char[contents.size()];

for (auto s : state) {
Expand Down Expand Up @@ -130,7 +130,7 @@ void BM_UValidate(benchmark::State& state) {

std::string zcontents;
snappy::Compress(contents.data(), contents.size(), &zcontents,
snappy::CompressionOptions{.level = state.range(1)});
snappy::CompressionOptions{/*level=*/state.range(1)});

for (auto s : state) {
CHECK(snappy::IsValidCompressedBuffer(zcontents.data(), zcontents.size()));
Expand Down Expand Up @@ -163,7 +163,7 @@ BENCHMARK(BM_UValidateMedley);
void BM_UIOVecSource(benchmark::State& state) {
// Pick file to process based on state.range(0).
int file_index = state.range(0);
int level = state.range(1);
int/*level=*/state.range(1);

CHECK_GE(file_index, 0);
CHECK_LT(file_index, ARRAYSIZE(kTestDataFiles));
Expand Down Expand Up @@ -193,7 +193,7 @@ void BM_UIOVecSource(benchmark::State& state) {
size_t zsize = 0;
for (auto s : state) {
snappy::RawCompressFromIOVec(iov, contents.size(), dst, &zsize,
snappy::CompressionOptions{.level = level});
snappy::CompressionOptions{/*level=*/level});
benchmark::DoNotOptimize(iov);
}
state.SetBytesProcessed(static_cast<int64_t>(state.iterations()) *
Expand Down Expand Up @@ -268,7 +268,7 @@ void BM_UFlatSink(benchmark::State& state) {

std::string zcontents;
snappy::Compress(contents.data(), contents.size(), &zcontents,
snappy::CompressionOptions{.level = state.range(1)});
snappy::CompressionOptions{/*level=*/state.range(1)});
char* dst = new char[contents.size()];

for (auto s : state) {
Expand All @@ -292,7 +292,7 @@ BENCHMARK(BM_UFlatSink)->Apply(FilesAndLevels);
void BM_ZFlat(benchmark::State& state) {
// Pick file to process based on state.range(0).
int file_index = state.range(0);
int level = state.range(1);
int/*level=*/state.range(1);

CHECK_GE(file_index, 0);
CHECK_LT(file_index, ARRAYSIZE(kTestDataFiles));
Expand All @@ -304,7 +304,7 @@ void BM_ZFlat(benchmark::State& state) {
size_t zsize = 0;
for (auto s : state) {
snappy::RawCompress(contents.data(), contents.size(), dst, &zsize,
snappy::CompressionOptions{.level = level});
snappy::CompressionOptions{/*level=*/level});
benchmark::DoNotOptimize(dst);
}
state.SetBytesProcessed(static_cast<int64_t>(state.iterations()) *
Expand All @@ -323,7 +323,7 @@ BENCHMARK(BM_ZFlat)->Apply(FilesAndLevels);

void BM_ZFlatAll(benchmark::State& state) {
const int num_files = ARRAYSIZE(kTestDataFiles);
int level = state.range(0);
int/*level=*/state.range(0);

std::vector<std::string> contents(num_files);
std::vector<char*> dst(num_files);
Expand All @@ -340,7 +340,7 @@ void BM_ZFlatAll(benchmark::State& state) {
for (auto s : state) {
for (int i = 0; i < num_files; ++i) {
snappy::RawCompress(contents[i].data(), contents[i].size(), dst[i],
&zsize, snappy::CompressionOptions{.level = level});
&zsize, snappy::CompressionOptions{/*level=*/level});
benchmark::DoNotOptimize(dst);
}
}
Expand All @@ -357,7 +357,7 @@ BENCHMARK(BM_ZFlatAll)->DenseRange(1, 2);

void BM_ZFlatIncreasingTableSize(benchmark::State& state) {
CHECK_GT(ARRAYSIZE(kTestDataFiles), 0);
int level = state.range(0);
int/*level=*/state.range(0);
const std::string base_content = ReadTestDataFile(
kTestDataFiles[0].filename, kTestDataFiles[0].size_limit);

Expand All @@ -377,7 +377,7 @@ void BM_ZFlatIncreasingTableSize(benchmark::State& state) {
for (auto s : state) {
for (size_t i = 0; i < contents.size(); ++i) {
snappy::RawCompress(contents[i].data(), contents[i].size(), dst[i],
&zsize, snappy::CompressionOptions{.level = level});
&zsize, snappy::CompressionOptions{/*level=*/level});
benchmark::DoNotOptimize(dst);
}
}
Expand Down
2 changes: 1 addition & 1 deletion snappy_compress_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
std::string compressed;
size_t compressed_size =
snappy::Compress(input.data(), input.size(), &compressed,
snappy::CompressionOptions{.level = level});
snappy::CompressionOptions{/*level=*/level});

(void)compressed_size; // Variable only used in debug builds.
assert(compressed_size == compressed.size());
Expand Down

0 comments on commit 4e693db

Please sign in to comment.