Skip to content

Commit

Permalink
[共通] fix #1101
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed Sep 22, 2023
1 parent 53f79b0 commit 5967299
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Siv3D/src/Siv3D/String/SivString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,20 @@ namespace s3d

String String::trimmed() const&
{
return String(std::find_if_not(m_string.begin(), m_string.end(), detail::IsTrimmable), std::find_if_not(m_string.rbegin(), m_string.rend(), detail::IsTrimmable).base());
const char32* start = m_string.data();
const char32* end = (start + m_string.size());

while ((start < end) && detail::IsTrimmable(*start))
{
++start;
}

while ((start < end) && detail::IsTrimmable(*(end - 1)))
{
--end;
}

return String(start, end);
}

String String::trimmed()&&
Expand Down

0 comments on commit 5967299

Please sign in to comment.