Fix lint errors
authorNicholas Ormrod <njormrod@fb.com>
Mon, 22 Sep 2014 21:13:14 +0000 (14:13 -0700)
committerAnton Likhtarov <alikhtarov@fb.com>
Fri, 26 Sep 2014 22:20:45 +0000 (15:20 -0700)
Summary: Pass const StringPieces by value instead of reference.

Test Plan:
fbconfig -r folly && fbmake runtests

Reviewed By: robbert@fb.com

Subscribers: trunkagent, sdwilsh, njormrod

FB internal diff: D1569488

folly/Range.cpp
folly/Range.h
folly/detail/SlowFingerprint.h
folly/gen/String-inl.h
folly/gen/String.h
folly/test/RangeFindBenchmark.cpp
folly/test/RangeTest.cpp

index 97d28b138db58069cf003fa312363a7dbdd38d23..42ee048d638dc25738794c70b28b95c86325868e 100644 (file)
@@ -32,20 +32,20 @@ namespace folly {
 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);
@@ -84,14 +84,14 @@ inline size_t nextAlignedIndex(const char* arr) {
 }
 
 // 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);
@@ -160,8 +160,8 @@ class FastByteSet {
 
 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);
@@ -177,8 +177,8 @@ size_t qfind_first_byte_of_byteset(const StringPiece& haystack,
 #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")))
@@ -193,8 +193,8 @@ size_t scanHaystackBlock(const StringPiece& haystack,
 // 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() ||
@@ -230,12 +230,12 @@ size_t scanHaystackBlock(const StringPiece& haystack,
   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) {
@@ -270,8 +270,8 @@ size_t qfind_first_byte_of_sse42(const StringPiece& haystack,
 }
 #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;
   }
index 1f8c1782188a473c7a7e1de552cfffa9fc093119..f61c76e9d4b577bad5d072d6d2cddc605f0815c2 100644 (file)
@@ -803,8 +803,8 @@ typedef Range<char*> MutableStringPiece;
 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
@@ -891,7 +891,7 @@ operator>=(const T& lhs, const U& rhs) {
 }
 
 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());
   }
 };
@@ -957,15 +957,15 @@ size_t qfind(const Range<T>& haystack,
 
 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;
@@ -973,8 +973,8 @@ inline size_t qfind_first_byte_of(const StringPiece& haystack,
 }
 
 #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
index c258e5f0b25a131bbbe19b4e1a1945352b898600..1e17bf30bec523b1e00ff076ad903be66a4d94bb 100644 (file)
@@ -54,7 +54,7 @@ class SlowFingerprint {
     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));
index 2eabad36a132e509e05068fd36d223b125047236..c22feee24373c3be8811ecd65a8daa435b2ea8ab 100644 (file)
@@ -269,7 +269,7 @@ class SplitStringSource
   StringPiece source_;
   DelimiterType delimiter_;
  public:
-  SplitStringSource(const StringPiece& source,
+  SplitStringSource(const StringPiece source,
                     DelimiterType delimiter)
     : source_(source)
     , delimiter_(std::move(delimiter)) { }
index af304f0e6b879ab1e080be095bb21bcbc736f1d2..17e662a0c5b3e711b8439c7245b5cd48ca912337 100644 (file)
@@ -60,7 +60,7 @@ S resplit(char 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);
 }
 
index 065e6a3faf8dce91517b5012f9f2eb16d2d9ba57..eecbf9c35b6823e3e492a08a5ca75e5d02340026 100644 (file)
 
 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;
@@ -131,15 +131,15 @@ BENCHMARK_RELATIVE(FindSingleCharRange, n) {
 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);
index 78e881a19062e0bed1ff97a11800f930e9504d7d..afc8ec8a8fa4cd130cc1d03f181a34d3db988de5 100644 (file)
 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