X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FRange.h;h=8e51760728a6e56817e98bf23d435fe483322672;hb=59527d6ae3453d12190f38762637c0fd19b6abd7;hp=c34d5cfe601efd766d7c43b3181422a02eae4686;hpb=b0131bea126f9febe31c825fc4cd11d5d8996304;p=folly.git diff --git a/folly/Range.h b/folly/Range.h index c34d5cfe..8e517607 100644 --- a/folly/Range.h +++ b/folly/Range.h @@ -48,6 +48,8 @@ #include #include #include +#include +#include // Ignore shadowing warnings within this file, so includers can use -Wshadow. #pragma GCC diagnostic push @@ -198,15 +200,10 @@ public: constexpr Range(Iter start, size_t size) : b_(start), e_(start + size) { } -#if FOLLY_HAVE_CONSTEXPR_STRLEN template ::type = 0> constexpr /* implicit */ Range(Iter str) - : b_(str), e_(str + strlen(str)) {} -#else - template ::type = 0> - /* implicit */ Range(Iter str) - : b_(str), e_(str + strlen(str)) {} -#endif + : b_(str), e_(str + constexpr_strlen(str)) {} + template ::const_type = 0> /* implicit */ Range(const std::string& str) : b_(str.data()), e_(b_ + str.size()) {} @@ -1000,13 +997,6 @@ size_t qfind(const Range& haystack, namespace detail { -size_t qfind_first_byte_of_nosse(const StringPiece haystack, - const StringPiece needles); - -#if FOLLY_HAVE_EMMINTRIN_H && __GNUC_PREREQ(4, 6) -size_t qfind_first_byte_of_sse42(const StringPiece haystack, - const StringPiece needles); - inline size_t qfind_first_byte_of(const StringPiece haystack, const StringPiece needles) { static auto const qfind_first_byte_of_fn = @@ -1015,13 +1005,6 @@ inline size_t qfind_first_byte_of(const StringPiece haystack, return qfind_first_byte_of_fn(haystack, needles); } -#else -inline size_t qfind_first_byte_of(const StringPiece haystack, - const StringPiece needles) { - return qfind_first_byte_of_nosse(haystack, needles); -} -#endif // FOLLY_HAVE_EMMINTRIN_H - } // namespace detail template @@ -1055,9 +1038,6 @@ struct AsciiCaseInsensitive { } }; -extern const AsciiCaseSensitive asciiCaseSensitive; -extern const AsciiCaseInsensitive asciiCaseInsensitive; - template size_t qfind(const Range& haystack, const typename Range::value_type& needle) { @@ -1115,7 +1095,7 @@ inline size_t rfind(const Range& haystack, template size_t qfind_first_of(const Range& haystack, const Range& needles) { - return qfind_first_of(haystack, needles, asciiCaseSensitive); + return qfind_first_of(haystack, needles, AsciiCaseSensitive()); } // specialization for StringPiece @@ -1133,10 +1113,12 @@ inline size_t qfind_first_of(const Range& haystack, StringPiece(needles)); } -template +template struct hasher; -template struct hasher> { +template +struct hasher, + typename std::enable_if::value, void>::type> { size_t operator()(folly::Range r) const { return hash::SpookyHashV2::Hash64(r.begin(), r.size() * sizeof(T), 0); }