| 36 | } |
| 37 | |
| 38 | std::string const* String::str_if_stable() const |
| 39 | { |
| 40 | if (!this->data()) { |
| 41 | // We view no string. |
| 42 | // This is stable for the lifetime of our current value. |
| 43 | return &empty_string_; |
| 44 | } |
| 45 | |
| 46 | if (this->string_ && this->data() == this->string_->data() && |
| 47 | this->size() == this->string_->size()) { |
| 48 | // We view an entire string. |
| 49 | // This is stable for the lifetime of our current value. |
| 50 | return this->string_.get(); |
| 51 | } |
| 52 | |
| 53 | return nullptr; |
| 54 | } |
| 55 | |
| 56 | std::string const& String::str() |
| 57 | { |