Commit 58d27d00 authored by Nicholas Ormrod's avatar Nicholas Ormrod Committed by Anton Likhtarov

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
parent 1a31dc64
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment