folly: deprecate StringPiece::hash
authorLucian Grijincu <lucian@fb.com>
Wed, 5 Oct 2016 20:49:26 +0000 (13:49 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Wed, 5 Oct 2016 20:53:38 +0000 (13:53 -0700)
Summary: It's bad mkey. Says so on the tin can. Alert/annoy its users.

Reviewed By: yfeldblum, ot

Differential Revision: D3973625

fbshipit-source-id: 23f4e16182749d016084fcb378a1170ff402c259

folly/Range.h

index 0ca0f6150aa6a69c6b48158033e1483dda699a13..97a7f1d082ba213f6c2025a855199bb171bdd00d 100644 (file)
@@ -442,6 +442,19 @@ public:
   // (The above advice does not apply if you are targeting a 32-bit system.)
   //
   // Works only for Range<const char*> and Range<char*>
+  //
+  //
+  //         ** WANT TO GET RID OF THIS LINT? **
+  //
+  // A) Use a better hash function (*cough*folly::Hash*cough*), but
+  //    only if you don't serialize data in a format that depends on
+  //    this formula (ie the writer and reader assume this exact hash
+  //    function is used).
+  //
+  // B) If you have to use this exact function then make your own hasher
+  //    object and copy the body over (see thrift example: D3972362).
+  //    https://github.com/facebook/fbthrift/commit/f8ed502e24ab4a32a9d5f266580
+  FOLLY_DEPRECATED("Replace with folly::Hash if the hash is not serialized")
   uint32_t hash() const {
     // Taken from fbi/nstring.h:
     //    Quick and dirty bernstein hash...fine for short ascii strings