Skip to content

Commit

Permalink
Fix all compilation errors to be C++11 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
danilak-G committed Apr 4, 2024
1 parent ab38064 commit 6b2eb70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions snappy.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ namespace snappy {
// faster decompression speeds than snappy:1 and zstd:-3.
int level = DefaultCompressionLevel();

constexpr CompressionOptions() = default;
constexpr CompressionOptions(int compression_level)
: level(compression_level) {}
static constexpr int MinCompressionLevel() { return 1; }
static constexpr int MaxCompressionLevel() { return 2; }
static constexpr int DefaultCompressionLevel() { return 1; }
Expand Down
25 changes: 13 additions & 12 deletions snappy_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@
#include <string>
#include <vector>

#include "snappy-test.h"

#include "benchmark/benchmark.h"

#include "snappy-internal.h"
#include "snappy-sinksource.h"
#include "snappy-test.h"
#include "snappy.h"
#include "snappy_test_data.h"

namespace snappy {

namespace {

void FilesAndLevels(::testing::Benchmark* benchmark) {
void FilesAndLevels(benchmark::internal::Benchmark* benchmark) {
for (int i = 0; i < ARRAYSIZE(kTestDataFiles); ++i) {
for (int level = snappy::CompressionOptions::MinCompressionLevel();
level <= snappy::CompressionOptions::MaxCompressionLevel(); ++level) {
Expand All @@ -64,8 +62,9 @@ void BM_UFlat(benchmark::State& state) {
kTestDataFiles[file_index].size_limit);

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

for (auto s : state) {
Expand Down Expand Up @@ -129,8 +128,9 @@ void BM_UValidate(benchmark::State& state) {
kTestDataFiles[file_index].size_limit);

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

for (auto s : state) {
CHECK(snappy::IsValidCompressedBuffer(zcontents.data(), zcontents.size()));
Expand Down Expand Up @@ -226,7 +226,7 @@ void BM_UIOVecSink(benchmark::State& state) {
// Uncompress into an iovec containing ten entries.
const int kNumEntries = 10;
struct iovec iov[kNumEntries];
char *dst = new char[contents.size()];
char* dst = new char[contents.size()];
size_t used_so_far = 0;
for (int i = 0; i < kNumEntries; ++i) {
iov[i].iov_base = dst + used_so_far;
Expand Down Expand Up @@ -267,8 +267,9 @@ void BM_UFlatSink(benchmark::State& state) {
kTestDataFiles[file_index].size_limit);

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

for (auto s : state) {
Expand Down Expand Up @@ -323,7 +324,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 Down

0 comments on commit 6b2eb70

Please sign in to comment.