diff options
author | crupest <crupest@outlook.com> | 2021-09-15 19:17:38 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-09-15 19:17:38 +0800 |
commit | cb981f5a337f3a8fc9d450b891c358c2b8dc29d3 (patch) | |
tree | 5216a09c127e534edfebca22f8b91d876812f6b4 /src/common | |
parent | 105e4ad880a810300bf4b3a0a0752ae58924667b (diff) | |
download | cru-cb981f5a337f3a8fc9d450b891c358c2b8dc29d3.tar.gz cru-cb981f5a337f3a8fc9d450b891c358c2b8dc29d3.tar.bz2 cru-cb981f5a337f3a8fc9d450b891c358c2b8dc29d3.zip |
...
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/String.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/common/String.cpp b/src/common/String.cpp index 602bcc51..3d3e4a3c 100644 --- a/src/common/String.cpp +++ b/src/common/String.cpp @@ -222,6 +222,11 @@ Range String::RangeFromCodePointToCodeUnit(Range code_point_range) const { IndexFromCodePointToCodeUnit(code_point_range.GetEnd())); } +String& String::operator+=(const String& other) { + append(other); + return *this; +} + namespace { inline int Compare(std::uint16_t left, std::uint16_t right) { if (left < right) return -1; @@ -305,9 +310,6 @@ void FormatAppendFromFormatTokenList( } } // namespace details -StringView::StringView(const std::uint16_t* ptr) - : ptr_(ptr), size_(GetStrSize(ptr)) {} - int StringView::Compare(const StringView& other) const { const_iterator i1 = cbegin(); const_iterator i2 = other.cbegin(); @@ -340,6 +342,7 @@ StringView StringView::substr(Index pos) { StringView StringView::substr(Index pos, Index size) { Expects(pos >= 0 && pos < size_); + return StringView(ptr_ + pos, std::min(size, size_ - pos)); } |