From 58d27d0059f83f3e608d30da331c4b938c005f2b Mon Sep 17 00:00:00 2001 From: Nicholas Ormrod Date: Fri, 13 Jun 2014 18:09:44 -0700 Subject: [PATCH] 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 --- folly/FBString.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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); } -- 2.34.1