diff --git a/opensource/.gitignore b/.gitignore similarity index 100% rename from opensource/.gitignore rename to .gitignore diff --git a/snappy-stubs-internal.cc b/snappy-stubs-internal.cc index 6ed3343..66ed2e9 100644 --- a/snappy-stubs-internal.cc +++ b/snappy-stubs-internal.cc @@ -33,7 +33,7 @@ namespace snappy { -void Varint::Append32(string* s, uint32 value) { +void Varint::Append32(std::string* s, uint32 value) { char buf[Varint::kMax32]; const char* p = Varint::Encode32(buf, value); s->append(buf, p - buf); diff --git a/snappy-stubs-internal.h b/snappy-stubs-internal.h index 716a949..4854689 100644 --- a/snappy-stubs-internal.h +++ b/snappy-stubs-internal.h @@ -524,7 +524,7 @@ class Varint { static char* Encode32(char* ptr, uint32 v); // EFFECTS Appends the varint representation of "value" to "*s". - static void Append32(string* s, uint32 value); + static void Append32(std::string* s, uint32 value); }; inline const char* Varint::Parse32WithLimit(const char* p, @@ -581,7 +581,7 @@ inline char* Varint::Encode32(char* sptr, uint32 v) { // replace this function with one that resizes the string without // filling the new space with zeros (if applicable) -- // it will be non-portable but faster. -inline void STLStringResizeUninitialized(string* s, size_t new_size) { +inline void STLStringResizeUninitialized(std::string* s, size_t new_size) { s->resize(new_size); } @@ -597,7 +597,7 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) { // (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-defects.html#530) // proposes this as the method. It will officially be part of the standard // for C++0x. This should already work on all current implementations. -inline char* string_as_array(string* str) { +inline char* string_as_array(std::string* str) { return str->empty() ? NULL : &*str->begin(); } diff --git a/snappy-test.cc b/snappy-test.cc index 01d5541..20524b2 100644 --- a/snappy-test.cc +++ b/snappy-test.cc @@ -48,12 +48,12 @@ DEFINE_bool(run_microbenchmarks, true, namespace snappy { -string ReadTestDataFile(const string& base, size_t size_limit) { - string contents; +std::string ReadTestDataFile(const std::string& base, size_t size_limit) { + std::string contents; const char* srcdir = getenv("srcdir"); // This is set by Automake. - string prefix; + std::string prefix; if (srcdir) { - prefix = string(srcdir) + "/"; + prefix = std::string(srcdir) + "/"; } file::GetContents(prefix + "testdata/" + base, &contents, file::Defaults() ).CheckSuccess(); @@ -63,11 +63,11 @@ string ReadTestDataFile(const string& base, size_t size_limit) { return contents; } -string ReadTestDataFile(const string& base) { +std::string ReadTestDataFile(const std::string& base) { return ReadTestDataFile(base, 0); } -string StringPrintf(const char* format, ...) { +std::string StringPrintf(const char* format, ...) { char buf[4096]; va_list ap; va_start(ap, format); @@ -79,7 +79,7 @@ string StringPrintf(const char* format, ...) { bool benchmark_running = false; int64 benchmark_real_time_us = 0; int64 benchmark_cpu_time_us = 0; -string *benchmark_label = NULL; +std::string* benchmark_label = nullptr; int64 benchmark_bytes_processed = 0; void ResetBenchmarkTiming() { @@ -163,11 +163,11 @@ void StopBenchmarkTiming() { benchmark_running = false; } -void SetBenchmarkLabel(const string& str) { +void SetBenchmarkLabel(const std::string& str) { if (benchmark_label) { delete benchmark_label; } - benchmark_label = new string(str); + benchmark_label = new std::string(str); } void SetBenchmarkBytesProcessed(int64 bytes) { @@ -217,8 +217,8 @@ void Benchmark::Run() { benchmark_runs[run].cpu_time_us = benchmark_cpu_time_us; } - string heading = StringPrintf("%s/%d", name_.c_str(), test_case_num); - string human_readable_speed; + std::string heading = StringPrintf("%s/%d", name_.c_str(), test_case_num); + std::string human_readable_speed; std::nth_element(benchmark_runs, benchmark_runs + kMedianPos, diff --git a/snappy-test.h b/snappy-test.h index 61e19f3..1996896 100644 --- a/snappy-test.h +++ b/snappy-test.h @@ -167,7 +167,7 @@ namespace file { namespace snappy { #define FLAGS_test_random_seed 301 -typedef string TypeParam; +using TypeParam = std::string; void Test_CorruptedTest_VerifyCorrupted(); void Test_Snappy_SimpleTests(); @@ -181,13 +181,13 @@ void Test_Snappy_ReadPastEndOfBuffer(); void Test_Snappy_FindMatchLength(); void Test_Snappy_FindMatchLengthRandom(); -string ReadTestDataFile(const string& base, size_t size_limit); +std::string ReadTestDataFile(const std::string& base, size_t size_limit); -string ReadTestDataFile(const string& base); +std::string ReadTestDataFile(const std::string& base); // A sprintf() variant that returns a std::string. // Not safe for general use due to truncation issues. -string StringPrintf(const char* format, ...); +std::string StringPrintf(const char* format, ...); // A wall-time clock. This stub is not super-accurate, nor resistant to the // system time changing. @@ -241,8 +241,8 @@ typedef void (*BenchmarkFunction)(int, int); class Benchmark { public: - Benchmark(const string& name, BenchmarkFunction function) : - name_(name), function_(function) {} + Benchmark(const std::string& name, BenchmarkFunction function) + : name_(name), function_(function) {} Benchmark* DenseRange(int start, int stop) { start_ = start; @@ -253,7 +253,7 @@ class Benchmark { void Run(); private: - const string name_; + const std::string name_; const BenchmarkFunction function_; int start_, stop_; }; @@ -271,7 +271,7 @@ extern Benchmark* Benchmark_BM_ZFlatIncreasingTableSize; void ResetBenchmarkTiming(); void StartBenchmarkTiming(); void StopBenchmarkTiming(); -void SetBenchmarkLabel(const string& str); +void SetBenchmarkLabel(const std::string& str); void SetBenchmarkBytesProcessed(int64 bytes); #ifdef HAVE_LIBZ diff --git a/snappy.cc b/snappy.cc index 2ce09a5..3ef0708 100644 --- a/snappy.cc +++ b/snappy.cc @@ -1346,7 +1346,7 @@ bool RawUncompress(Source* compressed, char* uncompressed) { return InternalUncompress(compressed, &output); } -bool Uncompress(const char* compressed, size_t n, string* uncompressed) { +bool Uncompress(const char* compressed, size_t n, std::string* uncompressed) { size_t ulength; if (!GetUncompressedLength(compressed, n, &ulength)) { return false; @@ -1414,7 +1414,8 @@ void RawCompress(const char* input, *compressed_length = (writer.CurrentDestination() - compressed); } -size_t Compress(const char* input, size_t input_length, string* compressed) { +size_t Compress(const char* input, size_t input_length, + std::string* compressed) { // Pre-grow the buffer to the max length of the compressed output STLStringResizeUninitialized(compressed, MaxCompressedLength(input_length)); diff --git a/snappy.h b/snappy.h index c46413a..e9805bf 100644 --- a/snappy.h +++ b/snappy.h @@ -69,11 +69,12 @@ namespace snappy { // Higher-level string based routines (should be sufficient for most users) // ------------------------------------------------------------------------ - // Sets "*output" to the compressed version of "input[0,input_length-1]". - // Original contents of *output are lost. + // Sets "*compressed" to the compressed version of "input[0,input_length-1]". + // Original contents of *compressed are lost. // - // REQUIRES: "input[]" is not an alias of "*output". - size_t Compress(const char* input, size_t input_length, string* output); + // REQUIRES: "input[]" is not an alias of "*compressed". + size_t Compress(const char* input, size_t input_length, + std::string* compressed); // Decompresses "compressed[0,compressed_length-1]" to "*uncompressed". // Original contents of "*uncompressed" are lost. @@ -82,7 +83,7 @@ namespace snappy { // // returns false if the message is corrupted and could not be decompressed bool Uncompress(const char* compressed, size_t compressed_length, - string* uncompressed); + std::string* uncompressed); // Decompresses "compressed" to "*uncompressed". // diff --git a/snappy_unittest.cc b/snappy_unittest.cc index 4e18180..e2eea82 100644 --- a/snappy_unittest.cc +++ b/snappy_unittest.cc @@ -73,7 +73,7 @@ namespace snappy { // be able to read previously allocated memory while doing heap allocations. class DataEndingAtUnreadablePage { public: - explicit DataEndingAtUnreadablePage(const string& s) { + explicit DataEndingAtUnreadablePage(const std::string& s) { const size_t page_size = sysconf(_SC_PAGESIZE); const size_t size = s.size(); // Round up space for string to a multiple of page_size. @@ -112,7 +112,7 @@ class DataEndingAtUnreadablePage { #else // defined(HAVE_FUNC_MMAP) && defined(HAVE_FUNC_SYSCONF) // Fallback for systems without mmap. -typedef string DataEndingAtUnreadablePage; +using DataEndingAtUnreadablePage = std::string; #endif @@ -154,7 +154,7 @@ static size_t MinimumRequiredOutputSpace(size_t input_size, // "compressed" must be preinitialized to at least MinCompressbufSize(comp) // number of bytes, and may contain junk bytes at the end after return. static bool Compress(const char* input, size_t input_size, CompressorType comp, - string* compressed, bool compressed_is_preallocated) { + std::string* compressed, bool compressed_is_preallocated) { if (!compressed_is_preallocated) { compressed->resize(MinimumRequiredOutputSpace(input_size, comp)); } @@ -215,8 +215,8 @@ static bool Compress(const char* input, size_t input_size, CompressorType comp, return true; } -static bool Uncompress(const string& compressed, CompressorType comp, - int size, string* output) { +static bool Uncompress(const std::string& compressed, CompressorType comp, + int size, std::string* output) { switch (comp) { #ifdef ZLIB_VERSION case ZLIB: { @@ -279,8 +279,8 @@ static void Measure(const char* data, int num_blocks = (length + block_size - 1) / block_size; std::vector input(num_blocks); std::vector input_length(num_blocks); - std::vector compressed(num_blocks); - std::vector output(num_blocks); + std::vector compressed(num_blocks); + std::vector output(num_blocks); for (int b = 0; b < num_blocks; b++) { int input_start = b * block_size; int input_limit = std::min((b+1)*block_size, length); @@ -344,11 +344,10 @@ static void Measure(const char* data, float comp_rate = (length / ctime[med]) * repeats / 1048576.0; float uncomp_rate = (length / utime[med]) * repeats / 1048576.0; - string x = names[comp]; + std::string x = names[comp]; x += ":"; - string urate = (uncomp_rate >= 0) - ? StringPrintf("%.1f", uncomp_rate) - : string("?"); + std::string urate = + (uncomp_rate >= 0) ? StringPrintf("%.1f", uncomp_rate) : std::string("?"); printf("%-7s [b %dM] bytes %6d -> %6d %4.1f%% " "comp %5.1f MB/s uncomp %5s MB/s\n", x.c_str(), @@ -359,8 +358,8 @@ static void Measure(const char* data, urate.c_str()); } -static int VerifyString(const string& input) { - string compressed; +static int VerifyString(const std::string& input) { + std::string compressed; DataEndingAtUnreadablePage i(input); const size_t written = snappy::Compress(i.data(), i.size(), &compressed); CHECK_EQ(written, compressed.size()); @@ -368,15 +367,15 @@ static int VerifyString(const string& input) { snappy::MaxCompressedLength(input.size())); CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size())); - string uncompressed; + std::string uncompressed; DataEndingAtUnreadablePage c(compressed); CHECK(snappy::Uncompress(c.data(), c.size(), &uncompressed)); CHECK_EQ(uncompressed, input); return uncompressed.size(); } -static void VerifyStringSink(const string& input) { - string compressed; +static void VerifyStringSink(const std::string& input) { + std::string compressed; DataEndingAtUnreadablePage i(input); const size_t written = snappy::Compress(i.data(), i.size(), &compressed); CHECK_EQ(written, compressed.size()); @@ -384,7 +383,7 @@ static void VerifyStringSink(const string& input) { snappy::MaxCompressedLength(input.size())); CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size())); - string uncompressed; + std::string uncompressed; uncompressed.resize(input.size()); snappy::UncheckedByteArraySink sink(string_as_array(&uncompressed)); DataEndingAtUnreadablePage c(compressed); @@ -393,8 +392,8 @@ static void VerifyStringSink(const string& input) { CHECK_EQ(uncompressed, input); } -static void VerifyIOVec(const string& input) { - string compressed; +static void VerifyIOVec(const std::string& input) { + std::string compressed; DataEndingAtUnreadablePage i(input); const size_t written = snappy::Compress(i.data(), i.size(), &compressed); CHECK_EQ(written, compressed.size()); @@ -440,13 +439,13 @@ static void VerifyIOVec(const string& input) { // Test that data compressed by a compressor that does not // obey block sizes is uncompressed properly. -static void VerifyNonBlockedCompression(const string& input) { +static void VerifyNonBlockedCompression(const std::string& input) { if (input.length() > snappy::kBlockSize) { // We cannot test larger blocks than the maximum block size, obviously. return; } - string prefix; + std::string prefix; Varint::Append32(&prefix, input.size()); // Setup compression table @@ -455,7 +454,7 @@ static void VerifyNonBlockedCompression(const string& input) { uint16* table = wmem.GetHashTable(input.size(), &table_size); // Compress entire input in one shot - string compressed; + std::string compressed; compressed += prefix; compressed.resize(prefix.size()+snappy::MaxCompressedLength(input.size())); char* dest = string_as_array(&compressed) + prefix.size(); @@ -463,13 +462,13 @@ static void VerifyNonBlockedCompression(const string& input) { dest, table, table_size); compressed.resize(end - compressed.data()); - // Uncompress into string - string uncomp_str; + // Uncompress into std::string + std::string uncomp_str; CHECK(snappy::Uncompress(compressed.data(), compressed.size(), &uncomp_str)); CHECK_EQ(uncomp_str, input); // Uncompress using source/sink - string uncomp_str2; + std::string uncomp_str2; uncomp_str2.resize(input.size()); snappy::UncheckedByteArraySink sink(string_as_array(&uncomp_str2)); snappy::ByteArraySource source(compressed.data(), compressed.size()); @@ -481,28 +480,28 @@ static void VerifyNonBlockedCompression(const string& input) { static const int kNumBlocks = 10; struct iovec vec[kNumBlocks]; const int block_size = 1 + input.size() / kNumBlocks; - string iovec_data(block_size * kNumBlocks, 'x'); + std::string iovec_data(block_size * kNumBlocks, 'x'); for (int i = 0; i < kNumBlocks; i++) { vec[i].iov_base = string_as_array(&iovec_data) + i * block_size; vec[i].iov_len = block_size; } CHECK(snappy::RawUncompressToIOVec(compressed.data(), compressed.size(), vec, kNumBlocks)); - CHECK_EQ(string(iovec_data.data(), input.size()), input); + CHECK_EQ(std::string(iovec_data.data(), input.size()), input); } } // Expand the input so that it is at least K times as big as block size -static string Expand(const string& input) { +static std::string Expand(const std::string& input) { static const int K = 3; - string data = input; + std::string data = input; while (data.size() < K * snappy::kBlockSize) { data += input; } return data; } -static int Verify(const string& input) { +static int Verify(const std::string& input) { VLOG(1) << "Verifying input of size " << input.size(); // Compress using string based routines @@ -514,7 +513,7 @@ static int Verify(const string& input) { VerifyNonBlockedCompression(input); VerifyIOVec(input); if (!input.empty()) { - const string expanded = Expand(input); + const std::string expanded = Expand(input); VerifyNonBlockedCompression(expanded); VerifyIOVec(input); } @@ -522,20 +521,20 @@ static int Verify(const string& input) { return result; } -static bool IsValidCompressedBuffer(const string& c) { +static bool IsValidCompressedBuffer(const std::string& c) { return snappy::IsValidCompressedBuffer(c.data(), c.size()); } -static bool Uncompress(const string& c, string* u) { +static bool Uncompress(const std::string& c, std::string* u) { return snappy::Uncompress(c.data(), c.size(), u); } // This test checks to ensure that snappy doesn't coredump if it gets // corrupted data. TEST(CorruptedTest, VerifyCorrupted) { - string source = "making sure we don't crash with corrupted input"; + std::string source = "making sure we don't crash with corrupted input"; VLOG(1) << source; - string dest; - string uncmp; + std::string dest; + std::string uncmp; snappy::Compress(source.data(), source.size(), &dest); // Mess around with the data. It's hard to simulate all possible @@ -582,9 +581,9 @@ TEST(CorruptedTest, VerifyCorrupted) { // try reading stuff in from a bad file. for (int i = 1; i <= 3; ++i) { - string data = ReadTestDataFile(StringPrintf("baddata%d.snappy", i).c_str(), - 0); - string uncmp; + std::string data = + ReadTestDataFile(StringPrintf("baddata%d.snappy", i).c_str(), 0); + std::string uncmp; // check that we don't return a crazy length size_t ulen; CHECK(!snappy::GetUncompressedLength(data.data(), data.size(), &ulen) @@ -602,7 +601,7 @@ TEST(CorruptedTest, VerifyCorrupted) { // These mirror the compression code in snappy.cc, but are copied // here so that we can bypass some limitations in the how snappy.cc // invokes these routines. -static void AppendLiteral(string* dst, const string& literal) { +static void AppendLiteral(std::string* dst, const std::string& literal) { if (literal.empty()) return; int n = literal.size() - 1; if (n < 60) { @@ -617,12 +616,12 @@ static void AppendLiteral(string* dst, const string& literal) { n >>= 8; } dst->push_back(0 | ((59+count) << 2)); - *dst += string(number, count); + *dst += std::string(number, count); } *dst += literal; } -static void AppendCopy(string* dst, int offset, int length) { +static void AppendCopy(std::string* dst, int offset, int length) { while (length > 0) { // Figure out how much to copy in one shot int to_copy; @@ -659,23 +658,23 @@ TEST(Snappy, SimpleTests) { Verify("ab"); Verify("abc"); - Verify("aaaaaaa" + string(16, 'b') + string("aaaaa") + "abc"); - Verify("aaaaaaa" + string(256, 'b') + string("aaaaa") + "abc"); - Verify("aaaaaaa" + string(2047, 'b') + string("aaaaa") + "abc"); - Verify("aaaaaaa" + string(65536, 'b') + string("aaaaa") + "abc"); - Verify("abcaaaaaaa" + string(65536, 'b') + string("aaaaa") + "abc"); + Verify("aaaaaaa" + std::string(16, 'b') + std::string("aaaaa") + "abc"); + Verify("aaaaaaa" + std::string(256, 'b') + std::string("aaaaa") + "abc"); + Verify("aaaaaaa" + std::string(2047, 'b') + std::string("aaaaa") + "abc"); + Verify("aaaaaaa" + std::string(65536, 'b') + std::string("aaaaa") + "abc"); + Verify("abcaaaaaaa" + std::string(65536, 'b') + std::string("aaaaa") + "abc"); } // Verify max blowup (lots of four-byte copies) TEST(Snappy, MaxBlowup) { std::mt19937 rng; std::uniform_int_distribution uniform_byte(0, 255); - string input; + std::string input; for (int i = 0; i < 80000; ++i) input.push_back(static_cast(uniform_byte(rng))); for (int i = 0; i < 80000; i += 4) { - string four_bytes(input.end() - i - 4, input.end() - i); + std::string four_bytes(input.end() - i - 4, input.end() - i); input.append(four_bytes); } Verify(input); @@ -696,7 +695,7 @@ TEST(Snappy, RandomData) { VLOG(0) << "Random op " << i << " of " << num_ops; } - string x; + std::string x; size_t len = uniform_4k(rng); if (i < 100) { len = 65536 + uniform_64k(rng); @@ -733,19 +732,19 @@ TEST(Snappy, FourByteOffset) { // copy manually. // The two fragments that make up the input string. - string fragment1 = "012345689abcdefghijklmnopqrstuvwxyz"; - string fragment2 = "some other string"; + std::string fragment1 = "012345689abcdefghijklmnopqrstuvwxyz"; + std::string fragment2 = "some other string"; // How many times each fragment is emitted. const int n1 = 2; const int n2 = 100000 / fragment2.size(); const int length = n1 * fragment1.size() + n2 * fragment2.size(); - string compressed; + std::string compressed; Varint::Append32(&compressed, length); AppendLiteral(&compressed, fragment1); - string src = fragment1; + std::string src = fragment1; for (int i = 0; i < n2; i++) { AppendLiteral(&compressed, fragment2); src += fragment2; @@ -754,7 +753,7 @@ TEST(Snappy, FourByteOffset) { src += fragment1; CHECK_EQ(length, src.size()); - string uncompressed; + std::string uncompressed; CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size())); CHECK(snappy::Uncompress(compressed.data(), compressed.size(), &uncompressed)); @@ -776,7 +775,7 @@ TEST(Snappy, IOVecEdgeCases) { iov[i].iov_len = kLengths[i]; } - string compressed; + std::string compressed; Varint::Append32(&compressed, 22); // A literal whose output crosses three blocks. @@ -837,7 +836,7 @@ TEST(Snappy, IOVecLiteralOverflow) { iov[i].iov_len = kLengths[i]; } - string compressed; + std::string compressed; Varint::Append32(&compressed, 8); AppendLiteral(&compressed, "12345678"); @@ -859,7 +858,7 @@ TEST(Snappy, IOVecCopyOverflow) { iov[i].iov_len = kLengths[i]; } - string compressed; + std::string compressed; Varint::Append32(&compressed, 8); AppendLiteral(&compressed, "123"); @@ -873,7 +872,7 @@ TEST(Snappy, IOVecCopyOverflow) { } } -static bool CheckUncompressedLength(const string& compressed, +static bool CheckUncompressedLength(const std::string& compressed, size_t* ulength) { const bool result1 = snappy::GetUncompressedLength(compressed.data(), compressed.size(), @@ -887,7 +886,7 @@ static bool CheckUncompressedLength(const string& compressed, } TEST(SnappyCorruption, TruncatedVarint) { - string compressed, uncompressed; + std::string compressed, uncompressed; size_t ulength; compressed.push_back('\xf0'); CHECK(!CheckUncompressedLength(compressed, &ulength)); @@ -897,7 +896,7 @@ TEST(SnappyCorruption, TruncatedVarint) { } TEST(SnappyCorruption, UnterminatedVarint) { - string compressed, uncompressed; + std::string compressed, uncompressed; size_t ulength; compressed.push_back('\x80'); compressed.push_back('\x80'); @@ -912,7 +911,7 @@ TEST(SnappyCorruption, UnterminatedVarint) { } TEST(SnappyCorruption, OverflowingVarint) { - string compressed, uncompressed; + std::string compressed, uncompressed; size_t ulength; compressed.push_back('\xfb'); compressed.push_back('\xff'); @@ -929,14 +928,14 @@ TEST(Snappy, ReadPastEndOfBuffer) { // Check that we do not read past end of input // Make a compressed string that ends with a single-byte literal - string compressed; + std::string compressed; Varint::Append32(&compressed, 1); AppendLiteral(&compressed, "x"); - string uncompressed; + std::string uncompressed; DataEndingAtUnreadablePage c(compressed); CHECK(snappy::Uncompress(c.data(), c.size(), &uncompressed)); - CHECK_EQ(uncompressed, string("x")); + CHECK_EQ(uncompressed, std::string("x")); } // Check for an infinite loop caused by a copy with offset==0 @@ -1065,7 +1064,7 @@ TEST(Snappy, FindMatchLengthRandom) { std::bernoulli_distribution one_in_typical_length(1.0 / kTypicalLength); for (int i = 0; i < kNumTrials; i++) { - string s, t; + std::string s, t; char a = static_cast(uniform_byte(rng)); char b = static_cast(uniform_byte(rng)); while (!one_in_typical_length(rng)) { @@ -1180,33 +1179,33 @@ TEST(Snappy, VerifyCharTable) { } static void CompressFile(const char* fname) { - string fullinput; + std::string fullinput; CHECK_OK(file::GetContents(fname, &fullinput, file::Defaults())); - string compressed; + std::string compressed; Compress(fullinput.data(), fullinput.size(), SNAPPY, &compressed, false); - CHECK_OK(file::SetContents(string(fname).append(".comp"), compressed, + CHECK_OK(file::SetContents(std::string(fname).append(".comp"), compressed, file::Defaults())); } static void UncompressFile(const char* fname) { - string fullinput; + std::string fullinput; CHECK_OK(file::GetContents(fname, &fullinput, file::Defaults())); size_t uncompLength; CHECK(CheckUncompressedLength(fullinput, &uncompLength)); - string uncompressed; + std::string uncompressed; uncompressed.resize(uncompLength); CHECK(snappy::Uncompress(fullinput.data(), fullinput.size(), &uncompressed)); - CHECK_OK(file::SetContents(string(fname).append(".uncomp"), uncompressed, + CHECK_OK(file::SetContents(std::string(fname).append(".uncomp"), uncompressed, file::Defaults())); } static void MeasureFile(const char* fname) { - string fullinput; + std::string fullinput; CHECK_OK(file::GetContents(fname, &fullinput, file::Defaults())); printf("%-40s :\n", fname); @@ -1259,10 +1258,10 @@ static void BM_UFlat(int iters, int arg) { // Pick file to process based on "arg" CHECK_GE(arg, 0); CHECK_LT(arg, ARRAYSIZE(files)); - string contents = ReadTestDataFile(files[arg].filename, - files[arg].size_limit); + std::string contents = + ReadTestDataFile(files[arg].filename, files[arg].size_limit); - string zcontents; + std::string zcontents; snappy::Compress(contents.data(), contents.size(), &zcontents); char* dst = new char[contents.size()]; @@ -1285,10 +1284,10 @@ static void BM_UValidate(int iters, int arg) { // Pick file to process based on "arg" CHECK_GE(arg, 0); CHECK_LT(arg, ARRAYSIZE(files)); - string contents = ReadTestDataFile(files[arg].filename, - files[arg].size_limit); + std::string contents = + ReadTestDataFile(files[arg].filename, files[arg].size_limit); - string zcontents; + std::string zcontents; snappy::Compress(contents.data(), contents.size(), &zcontents); SetBenchmarkBytesProcessed(static_cast(iters) * @@ -1308,10 +1307,10 @@ static void BM_UIOVec(int iters, int arg) { // Pick file to process based on "arg" CHECK_GE(arg, 0); CHECK_LT(arg, ARRAYSIZE(files)); - string contents = ReadTestDataFile(files[arg].filename, - files[arg].size_limit); + std::string contents = + ReadTestDataFile(files[arg].filename, files[arg].size_limit); - string zcontents; + std::string zcontents; snappy::Compress(contents.data(), contents.size(), &zcontents); // Uncompress into an iovec containing ten entries. @@ -1354,10 +1353,10 @@ static void BM_UFlatSink(int iters, int arg) { // Pick file to process based on "arg" CHECK_GE(arg, 0); CHECK_LT(arg, ARRAYSIZE(files)); - string contents = ReadTestDataFile(files[arg].filename, - files[arg].size_limit); + std::string contents = + ReadTestDataFile(files[arg].filename, files[arg].size_limit); - string zcontents; + std::string zcontents; snappy::Compress(contents.data(), contents.size(), &zcontents); char* dst = new char[contents.size()]; @@ -1372,7 +1371,7 @@ static void BM_UFlatSink(int iters, int arg) { } StopBenchmarkTiming(); - string s(dst, contents.size()); + std::string s(dst, contents.size()); CHECK_EQ(contents, s); delete[] dst; @@ -1386,8 +1385,8 @@ static void BM_ZFlat(int iters, int arg) { // Pick file to process based on "arg" CHECK_GE(arg, 0); CHECK_LT(arg, ARRAYSIZE(files)); - string contents = ReadTestDataFile(files[arg].filename, - files[arg].size_limit); + std::string contents = + ReadTestDataFile(files[arg].filename, files[arg].size_limit); char* dst = new char[snappy::MaxCompressedLength(contents.size())];