Fix all compilation errors to be C++11 compliant

This commit is contained in:
Danila Kutenin 2024-04-04 19:00:14 +00:00
parent ab38064abe
commit 6b2eb7028b
2 changed files with 16 additions and 12 deletions

View File

@ -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; }

View File

@ -31,12 +31,10 @@
#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"
@ -44,7 +42,7 @@ 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) {
@ -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) {
@ -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()));
@ -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) {
@ -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);