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
};
union {
- mutable Char small_[sizeof(MediumLarge) / sizeof(Char)];
- mutable MediumLarge ml_;
+ Char small_[sizeof(MediumLarge) / sizeof(Char)];
+ MediumLarge ml_;
};
enum {
// 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);
}