| 765 | } |
| 766 | |
| 767 | std::string_view SmallStringBase::substr(s32 offset, s32 count) const |
| 768 | { |
| 769 | // calc real offset |
| 770 | u32 real_offset; |
| 771 | if (offset < 0) |
| 772 | real_offset = static_cast<u32>(std::max<s32>(0, static_cast<s32>(m_length + offset))); |
| 773 | else |
| 774 | real_offset = std::min((u32)offset, m_length); |
| 775 | |
| 776 | // calc real count |
| 777 | u32 real_count; |
| 778 | if (count < 0) |
| 779 | { |
| 780 | real_count = |
| 781 | std::min(m_length - real_offset, static_cast<u32>(std::max<s32>(0, static_cast<s32>(m_length) + count))); |
| 782 | } |
| 783 | else |
| 784 | { |
| 785 | real_count = std::min(m_length - real_offset, static_cast<u32>(count)); |
| 786 | } |
| 787 | |
| 788 | return (real_count > 0) ? std::string_view(m_buffer + real_offset, real_count) : std::string_view(); |
| 789 | } |
| 790 | |
| 791 | void SmallStringBase::erase(s32 offset, s32 count) |
| 792 | { |