From 0c13ae5fa4716e86815d129c1ed88c5fe55cdd44 Mon Sep 17 00:00:00 2001 From: Davi de Castro Reis Date: Fri, 1 Jun 2012 17:49:00 -0300 Subject: [PATCH] Compiles with clang. --- cxxmph/Makefile.am | 7 +- cxxmph/bm_index.cc | 6 ++ cxxmph/bm_map.cc | 2 +- cxxmph/map_tester.cc | 4 -- cxxmph/map_tester.h | 23 ++++--- cxxmph/string_util.cc | 23 +++++++ cxxmph/string_util.h | 137 ++++++++++++++++++++++++++++++++++++++ src/bdz.c | 18 ++--- src/bdz_ph.c | 18 ++--- src/bm_numbers.c | 2 +- src/bmz.c | 10 +-- src/bmz8.c | 10 +-- src/brz.c | 18 ++--- src/chd.c | 8 +-- src/chd_ph.c | 10 +-- src/chm.c | 10 +-- src/cmph_benchmark.c | 2 +- src/cmph_structs.c | 2 +- src/fch.c | 10 +-- src/fch_buckets.c | 6 +- src/hash.c | 2 +- src/main.c | 4 +- tests/packed_mphf_tests.c | 2 +- 23 files changed, 251 insertions(+), 83 deletions(-) create mode 100644 cxxmph/string_util.cc create mode 100644 cxxmph/string_util.h diff --git a/cxxmph/Makefile.am b/cxxmph/Makefile.am index 04ba47e..268b2f9 100644 --- a/cxxmph/Makefile.am +++ b/cxxmph/Makefile.am @@ -1,9 +1,9 @@ TESTS = $(check_PROGRAMS) -check_PROGRAMS = seeded_hash_test mph_bits_test hollow_iterator_test mph_map_test mph_index_test trigraph_test map_tester_test +check_PROGRAMS = seeded_hash_test mph_bits_test hollow_iterator_test mph_map_test mph_index_test trigraph_test map_tester_test string_util_test noinst_PROGRAMS = bm_index bm_map bin_PROGRAMS = cxxmph lib_LTLIBRARIES = libcxxmph.la -libcxxmph_la_SOURCES = MurmurHash3.h MurmurHash3.cpp trigragh.h trigraph.cc mph_bits.h mph_bits.cc mph_index.h mph_index.cc seeded_hash.h stringpiece.h benchmark.h benchmark.cc +libcxxmph_la_SOURCES = MurmurHash3.h MurmurHash3.cpp trigragh.h trigraph.cc mph_bits.h mph_bits.cc mph_index.h mph_index.cc seeded_hash.h stringpiece.h benchmark.h benchmark.cc string_util.cc libcxxmph_la_LDFLAGS = -version-info 0:0:0 cxxmph_includedir = $(includedir)/cxxmph/ cxxmph_include_HEADERS = mph_map.h mph_index.h MurmurHash3.h trigraph.h seeded_hash.h stringpiece.h hollow_iterator.h @@ -34,5 +34,8 @@ seeded_hash_test_LDADD = libcxxmph.la mph_bits_test_SOURCES = mph_bits_test.cc mph_bits_test_LDADD = libcxxmph.la +string_util_test_SOURCES = string_util_test.cc +string_util_test_LDADD = libcxxmph.la + map_tester_test_SOURCES = map_tester.cc map_tester_test.cc diff --git a/cxxmph/bm_index.cc b/cxxmph/bm_index.cc index d1cbc00..4dd7156 100644 --- a/cxxmph/bm_index.cc +++ b/cxxmph/bm_index.cc @@ -44,10 +44,12 @@ class BM_MPHIndexSearch : public SearchUrlsBenchmark { BM_MPHIndexSearch(const std::string& urls_file, int nsearches) : SearchUrlsBenchmark(urls_file, nsearches, 0) { } virtual void Run() { + uint64_t sum = 0; for (auto it = random_.begin(); it != random_.end(); ++it) { auto idx = index_.index(*it); // Collision check to be fair with STL if (strcmp(urls_[idx].c_str(), it->data()) != 0) idx = -1; + sum += idx; } } protected: @@ -65,10 +67,12 @@ class BM_CmphIndexSearch : public SearchUrlsBenchmark { : SearchUrlsBenchmark(urls_file, nsearches, 0) { } ~BM_CmphIndexSearch() { if (index_) cmph_destroy(index_); } virtual void Run() { + uint64_t sum = 0; for (auto it = random_.begin(); it != random_.end(); ++it) { auto idx = cmph_search(index_, it->data(), it->length()); // Collision check to be fair with STL if (strcmp(urls_[idx].c_str(), it->data()) != 0) idx = -1; + sum += idx; } } protected: @@ -114,8 +118,10 @@ class BM_STLIndexSearch : public SearchUrlsBenchmark { BM_STLIndexSearch(const std::string& urls_file, int nsearches) : SearchUrlsBenchmark(urls_file, nsearches, 0) { } virtual void Run() { + uint64_t sum = 0; for (auto it = random_.begin(); it != random_.end(); ++it) { auto idx = index_.find(*it); + sum += idx->second; } } protected: diff --git a/cxxmph/bm_map.cc b/cxxmph/bm_map.cc index 115f7f8..f777a2b 100644 --- a/cxxmph/bm_map.cc +++ b/cxxmph/bm_map.cc @@ -1,5 +1,5 @@ #include -#include +#include #include "bm_common.h" #include "mph_map.h" diff --git a/cxxmph/map_tester.cc b/cxxmph/map_tester.cc index fdae9d1..96b04f4 100644 --- a/cxxmph/map_tester.cc +++ b/cxxmph/map_tester.cc @@ -1,8 +1,4 @@ #include "map_tester.h" namespace cxxxmph { - -MapTester::MapTester() {} -MapTester::~MapTester() {} - } diff --git a/cxxmph/map_tester.h b/cxxmph/map_tester.h index 7a2dd4a..811860c 100644 --- a/cxxmph/map_tester.h +++ b/cxxmph/map_tester.h @@ -7,15 +7,18 @@ #include #include +#include "string_util.h" + namespace cxxmph { using namespace std; -// template