From ed3b7b242bd24de2ca6750c73f64bee5b7505944 Mon Sep 17 00:00:00 2001 From: costan Date: Fri, 17 Mar 2017 13:43:18 -0700 Subject: [PATCH] Clean up unused function warnings in snappy. --- snappy-internal.h | 5 ----- snappy-test.h | 21 ++++----------------- snappy.cc | 9 ++++++++- snappy_unittest.cc | 10 ++++------ 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/snappy-internal.h b/snappy-internal.h index b8355c0..d2a22e8 100644 --- a/snappy-internal.h +++ b/snappy-internal.h @@ -170,11 +170,6 @@ enum { }; static const int kMaximumTagLength = 5; // COPY_4_BYTE_OFFSET plus the actual offset. -// Mapping from i in range [0,4] to a mask to extract the bottom 8*i bits -static const uint32 wordmask[] = { - 0u, 0xffu, 0xffffu, 0xffffffu, 0xffffffffu -}; - // Data stored per entry in lookup table: // Range Bits-used Description // ------------------------------------ diff --git a/snappy-test.h b/snappy-test.h index b251e66..7b39a8c 100644 --- a/snappy-test.h +++ b/snappy-test.h @@ -126,10 +126,6 @@ extern "C" { namespace { -namespace File { - void Init() { } -} // namespace File - namespace file { int Defaults() { return 0; } @@ -162,9 +158,8 @@ namespace file { return DummyStatus(); } - DummyStatus SetContents(const std::string& filename, - const std::string& str, - int unused) { + inline DummyStatus SetContents( + const std::string& filename, const std::string& str, int unused) { FILE* fp = fopen(filename.c_str(), "wb"); if (fp == NULL) { perror(filename.c_str()); @@ -468,7 +463,7 @@ class ZLib { DECLARE_bool(run_microbenchmarks); -static void RunSpecifiedBenchmarks() { +static inline void RunSpecifiedBenchmarks() { if (!FLAGS_run_microbenchmarks) { return; } @@ -516,10 +511,6 @@ static inline int RUN_ALL_TESTS() { // For main(). namespace snappy { -static void CompressFile(const char* fname); -static void UncompressFile(const char* fname); -static void MeasureFile(const char* fname); - // Logging. #define LOG(level) LogMessage() @@ -591,10 +582,6 @@ class LogMessageVoidify { #define CHECK_GT(a, b) CRASH_UNLESS((a) > (b)) #define CHECK_OK(cond) (cond).CheckSuccess() -} // namespace - -using snappy::CompressFile; -using snappy::UncompressFile; -using snappy::MeasureFile; +} // namespace snappy #endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_ diff --git a/snappy.cc b/snappy.cc index a00b872..90c0787 100644 --- a/snappy.cc +++ b/snappy.cc @@ -47,7 +47,6 @@ using internal::COPY_2_BYTE_OFFSET; using internal::LITERAL; using internal::char_table; using internal::kMaximumTagLength; -using internal::wordmask; // Any hash function will produce a valid compressed bitstream, but a good // hash function reduces the number of collisions and thus yields better @@ -575,6 +574,14 @@ static inline void Report(const char *algorithm, size_t compressed_size, // bool TryFastAppend(const char* ip, size_t available, size_t length); // }; +namespace internal { + +// Mapping from i in range [0,4] to a mask to extract the bottom 8*i bits +static const uint32 wordmask[] = { + 0u, 0xffu, 0xffffu, 0xffffffu, 0xffffffffu +}; + +} // end namespace internal // Helper class for decompression class SnappyDecompressor { diff --git a/snappy_unittest.cc b/snappy_unittest.cc index 3a12f7e..32d766e 100644 --- a/snappy_unittest.cc +++ b/snappy_unittest.cc @@ -32,6 +32,7 @@ #include #include +#include #include #include "snappy.h" @@ -69,7 +70,6 @@ DEFINE_bool(snappy_dump_decompression_table, false, namespace snappy { - #ifdef HAVE_FUNC_MMAP // To test against code that reads beyond its input, this class copies a @@ -1197,7 +1197,6 @@ TEST(Snappy, VerifyCharTable) { using snappy::internal::COPY_2_BYTE_OFFSET; using snappy::internal::COPY_4_BYTE_OFFSET; using snappy::internal::char_table; - using snappy::internal::wordmask; uint16 dst[256]; @@ -1509,7 +1508,6 @@ BENCHMARK(BM_ZFlat)->DenseRange(0, ARRAYSIZE(files) - 1); } // namespace snappy - int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); RunSpecifiedBenchmarks(); @@ -1517,11 +1515,11 @@ int main(int argc, char** argv) { if (argc >= 2) { for (int arg = 1; arg < argc; arg++) { if (FLAGS_write_compressed) { - CompressFile(argv[arg]); + snappy::CompressFile(argv[arg]); } else if (FLAGS_write_uncompressed) { - UncompressFile(argv[arg]); + snappy::UncompressFile(argv[arg]); } else { - MeasureFile(argv[arg]); + snappy::MeasureFile(argv[arg]); } } return 0;