From: Nicholas Ormrod Date: Sat, 14 Jun 2014 01:09:44 +0000 (-0700) Subject: FBString conservative additions X-Git-Tag: v0.22.0~507 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=58d27d0059f83f3e608d30da331c4b938c005f2b;p=folly.git FBString conservative additions Summary: Now that fbstring is conservative by default (D1373308), we can remove the mutability of the data members and the call to c_str() in operator[]. Test Plan: fbconfig -r folly && fbmake runtests Reviewed By: lucian@fb.com Subscribers: folly@lists, sdwilsh, njormrod FB internal diff: D1382644 --- diff --git a/folly/FBString.h b/folly/FBString.h index 14723534..2f4c9a44 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -797,8 +797,8 @@ private: }; union { - mutable Char small_[sizeof(MediumLarge) / sizeof(Char)]; - mutable MediumLarge ml_; + Char small_[sizeof(MediumLarge) / sizeof(Char)]; + MediumLarge ml_; }; enum { @@ -1247,14 +1247,10 @@ public: // C++11 21.4.5 element access: const_reference operator[](size_type pos) const { - return *(c_str() + pos); + return *(begin() + pos); } reference operator[](size_type pos) { - if (pos == size()) { - // Just call c_str() to make sure '\0' is present - c_str(); - } return *(begin() + pos); }