const AsciiCaseSensitive asciiCaseSensitive = AsciiCaseSensitive();
const AsciiCaseInsensitive asciiCaseInsensitive = AsciiCaseInsensitive();
-std::ostream& operator<<(std::ostream& os, const StringPiece& piece) {
+std::ostream& operator<<(std::ostream& os, const StringPiece piece) {
os.write(piece.start(), piece.size());
return os;
}
-std::ostream& operator<<(std::ostream& os, const MutableStringPiece& piece) {
+std::ostream& operator<<(std::ostream& os, const MutableStringPiece piece) {
os.write(piece.start(), piece.size());
return os;
}
namespace detail {
-size_t qfind_first_byte_of_memchr(const StringPiece& haystack,
- const StringPiece& needles) {
+size_t qfind_first_byte_of_memchr(const StringPiece haystack,
+ const StringPiece needles) {
size_t best = haystack.size();
for (char needle: needles) {
const void* ptr = memchr(haystack.data(), needle, best);
}
// build sse4.2-optimized version even if -msse4.2 is not passed to GCC
-size_t qfind_first_byte_of_needles16(const StringPiece& haystack,
- const StringPiece& needles)
+size_t qfind_first_byte_of_needles16(const StringPiece haystack,
+ const StringPiece needles)
__attribute__ ((__target__("sse4.2"), noinline))
FOLLY_DISABLE_ADDRESS_SANITIZER;
// helper method for case where needles.size() <= 16
-size_t qfind_first_byte_of_needles16(const StringPiece& haystack,
- const StringPiece& needles) {
+size_t qfind_first_byte_of_needles16(const StringPiece haystack,
+ const StringPiece needles) {
DCHECK(!haystack.empty());
DCHECK(!needles.empty());
DCHECK_LE(needles.size(), 16);
namespace detail {
-size_t qfind_first_byte_of_byteset(const StringPiece& haystack,
- const StringPiece& needles) {
+size_t qfind_first_byte_of_byteset(const StringPiece haystack,
+ const StringPiece needles) {
FastByteSet s;
for (auto needle: needles) {
s.add(needle);
#if FOLLY_HAVE_EMMINTRIN_H && __GNUC_PREREQ(4, 6)
template <bool HAYSTACK_ALIGNED>
-size_t scanHaystackBlock(const StringPiece& haystack,
- const StringPiece& needles,
+size_t scanHaystackBlock(const StringPiece haystack,
+ const StringPiece needles,
int64_t idx)
// inline is okay because it's only called from other sse4.2 functions
__attribute__ ((__target__("sse4.2")))
// If !HAYSTACK_ALIGNED, then caller must ensure that it is safe to load the
// block.
template <bool HAYSTACK_ALIGNED>
-size_t scanHaystackBlock(const StringPiece& haystack,
- const StringPiece& needles,
+size_t scanHaystackBlock(const StringPiece haystack,
+ const StringPiece needles,
int64_t blockStartIdx) {
DCHECK_GT(needles.size(), 16); // should handled by *needles16() method
DCHECK(blockStartIdx + 16 <= haystack.size() ||
return StringPiece::npos;
}
-size_t qfind_first_byte_of_sse42(const StringPiece& haystack,
- const StringPiece& needles)
+size_t qfind_first_byte_of_sse42(const StringPiece haystack,
+ const StringPiece needles)
__attribute__ ((__target__("sse4.2"), noinline));
-size_t qfind_first_byte_of_sse42(const StringPiece& haystack,
- const StringPiece& needles) {
+size_t qfind_first_byte_of_sse42(const StringPiece haystack,
+ const StringPiece needles) {
if (UNLIKELY(needles.empty() || haystack.empty())) {
return StringPiece::npos;
} else if (needles.size() <= 16) {
}
#endif // FOLLY_HAVE_EMMINTRIN_H && GCC 4.6+
-size_t qfind_first_byte_of_nosse(const StringPiece& haystack,
- const StringPiece& needles) {
+size_t qfind_first_byte_of_nosse(const StringPiece haystack,
+ const StringPiece needles) {
if (UNLIKELY(needles.empty() || haystack.empty())) {
return StringPiece::npos;
}
typedef Range<const unsigned char*> ByteRange;
typedef Range<unsigned char*> MutableByteRange;
-std::ostream& operator<<(std::ostream& os, const StringPiece& piece);
-std::ostream& operator<<(std::ostream& os, const MutableStringPiece& piece);
+std::ostream& operator<<(std::ostream& os, const StringPiece piece);
+std::ostream& operator<<(std::ostream& os, const MutableStringPiece piece);
/**
* Templated comparison operators
}
struct StringPieceHash {
- std::size_t operator()(const StringPiece& str) const {
+ std::size_t operator()(const StringPiece str) const {
return static_cast<std::size_t>(str.hash());
}
};
namespace detail {
-size_t qfind_first_byte_of_nosse(const StringPiece& haystack,
- const StringPiece& needles);
+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);
+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) {
+inline size_t qfind_first_byte_of(const StringPiece haystack,
+ const StringPiece needles) {
static auto const qfind_first_byte_of_fn =
folly::CpuId().sse42() ? qfind_first_byte_of_sse42
: qfind_first_byte_of_nosse;
}
#else
-inline size_t qfind_first_byte_of(const StringPiece& haystack,
- const StringPiece& needles) {
+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
return *this;
}
- SlowFingerprint& update(const folly::StringPiece& str) {
+ SlowFingerprint& update(const folly::StringPiece str) {
const char* p = str.start();
for (int i = str.size(); i != 0; p++, i--) {
update8(static_cast<uint8_t>(*p));
StringPiece source_;
DelimiterType delimiter_;
public:
- SplitStringSource(const StringPiece& source,
+ SplitStringSource(const StringPiece source,
DelimiterType delimiter)
: source_(source)
, delimiter_(std::move(delimiter)) { }
}
template <class S = detail::SplitStringSource<char>>
-S split(const StringPiece& source, char delimiter) {
+S split(const StringPiece source, char delimiter) {
return S(source, delimiter);
}
namespace folly { namespace detail {
// declaration of functions in Range.cpp
-size_t qfind_first_byte_of_memchr(const StringPiece& haystack,
- const StringPiece& needles);
+size_t qfind_first_byte_of_memchr(const StringPiece haystack,
+ const StringPiece needles);
-size_t qfind_first_byte_of_byteset(const StringPiece& haystack,
- const StringPiece& needles);
+size_t qfind_first_byte_of_byteset(const StringPiece haystack,
+ const StringPiece needles);
-size_t qfind_first_byte_of_nosse(const StringPiece& haystack,
- const StringPiece& needles);
+size_t qfind_first_byte_of_nosse(const StringPiece haystack,
+ const StringPiece needles);
}}
using namespace folly;
BENCHMARK_DRAW_LINE();
// it's useful to compare our custom implementations vs. the standard library
-inline size_t qfind_first_byte_of_std(const StringPiece& haystack,
- const StringPiece& needles) {
+inline size_t qfind_first_byte_of_std(const StringPiece haystack,
+ const StringPiece needles) {
return qfind_first_of(haystack, needles, asciiCaseSensitive);
}
template <class Func>
void findFirstOfRange(StringPiece needles, Func func, size_t n) {
FOR_EACH_RANGE (i, 0, n) {
- const StringPiece& haystack = vstr[i % kVstrSize];
+ const StringPiece haystack = vstr[i % kVstrSize];
doNotOptimizeAway(func(haystack, needles));
char x = haystack[0];
doNotOptimizeAway(&x);
namespace folly { namespace detail {
// declaration of functions in Range.cpp
-size_t qfind_first_byte_of_memchr(const StringPiece& haystack,
- const StringPiece& needles);
+size_t qfind_first_byte_of_memchr(const StringPiece haystack,
+ const StringPiece needles);
-size_t qfind_first_byte_of_byteset(const StringPiece& haystack,
- const StringPiece& needles);
+size_t qfind_first_byte_of_byteset(const StringPiece haystack,
+ const StringPiece needles);
}} // namespaces