Commit 40673e01 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by facebook-github-bot-4

No need to export global instances of folly::AsciiCase(Ins|S)ensitive

Summary: [Folly] No need to export global instances of `folly::AsciiCaseInsensitive` and `folly::AsciiCaseSensitive`.

Calling code may simply construct instances at will - the compiler will optimize away the object construction since it has only the default ctor/dtor, no storage, and no vtable.

Reviewed By: @fugalh

Differential Revision: D2437419
parent b57fd1bc
...@@ -26,12 +26,6 @@ ...@@ -26,12 +26,6 @@
namespace folly { namespace folly {
/**
* Predicates that can be used with qfind and startsWith
*/
const AsciiCaseSensitive asciiCaseSensitive = AsciiCaseSensitive();
const AsciiCaseInsensitive asciiCaseInsensitive = AsciiCaseInsensitive();
namespace { namespace {
// It's okay if pages are bigger than this (as powers of two), but they should // It's okay if pages are bigger than this (as powers of two), but they should
...@@ -216,7 +210,7 @@ size_t qfind_first_byte_of_sse42(const StringPiece haystack, ...@@ -216,7 +210,7 @@ size_t qfind_first_byte_of_sse42(const StringPiece haystack,
PAGE_FOR(haystack.end() - 1) != PAGE_FOR(haystack.data() + 16)) { PAGE_FOR(haystack.end() - 1) != PAGE_FOR(haystack.data() + 16)) {
// We can't safely SSE-load haystack. Use a different approach. // We can't safely SSE-load haystack. Use a different approach.
if (haystack.size() <= 2) { if (haystack.size() <= 2) {
return qfind_first_of(haystack, needles, asciiCaseSensitive); return qfind_first_of(haystack, needles, AsciiCaseSensitive());
} }
return qfind_first_byte_of_byteset(haystack, needles); return qfind_first_byte_of_byteset(haystack, needles);
} }
...@@ -251,7 +245,7 @@ size_t qfind_first_byte_of_nosse(const StringPiece haystack, ...@@ -251,7 +245,7 @@ size_t qfind_first_byte_of_nosse(const StringPiece haystack,
needles.size() >= 32) { needles.size() >= 32) {
return qfind_first_byte_of_byteset(haystack, needles); return qfind_first_byte_of_byteset(haystack, needles);
} }
return qfind_first_of(haystack, needles, asciiCaseSensitive); return qfind_first_of(haystack, needles, AsciiCaseSensitive());
} }
} // namespace detail } // namespace detail
......
...@@ -1055,9 +1055,6 @@ struct AsciiCaseInsensitive { ...@@ -1055,9 +1055,6 @@ struct AsciiCaseInsensitive {
} }
}; };
extern const AsciiCaseSensitive asciiCaseSensitive;
extern const AsciiCaseInsensitive asciiCaseInsensitive;
template <class T> template <class T>
size_t qfind(const Range<T>& haystack, size_t qfind(const Range<T>& haystack,
const typename Range<T>::value_type& needle) { const typename Range<T>::value_type& needle) {
...@@ -1115,7 +1112,7 @@ inline size_t rfind(const Range<const unsigned char*>& haystack, ...@@ -1115,7 +1112,7 @@ inline size_t rfind(const Range<const unsigned char*>& haystack,
template <class T> template <class T>
size_t qfind_first_of(const Range<T>& haystack, size_t qfind_first_of(const Range<T>& haystack,
const Range<T>& needles) { const Range<T>& needles) {
return qfind_first_of(haystack, needles, asciiCaseSensitive); return qfind_first_of(haystack, needles, AsciiCaseSensitive());
} }
// specialization for StringPiece // specialization for StringPiece
......
...@@ -144,7 +144,7 @@ BENCHMARK_DRAW_LINE(); ...@@ -144,7 +144,7 @@ BENCHMARK_DRAW_LINE();
// it's useful to compare our custom implementations vs. the standard library // it's useful to compare our custom implementations vs. the standard library
inline size_t qfind_first_byte_of_std(const StringPiece haystack, inline size_t qfind_first_byte_of_std(const StringPiece haystack,
const StringPiece needles) { const StringPiece needles) {
return qfind_first_of(haystack, needles, asciiCaseSensitive); return qfind_first_of(haystack, needles, AsciiCaseSensitive());
} }
template <class Func> template <class Func>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment