Skip to content

Commit

Permalink
Simplify code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim committed Nov 8, 2024
1 parent dbfcc05 commit 508bf97
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/util/StringUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,26 @@ std::string StringUtil::strip(const std::string& str)
if (!str.empty())
{
const char *cur = str.c_str();
const char *end = cur + str.size() - 1;
const char *end = cur + str.size();

while (cur <= end)
while (cur < end)
{
if (!isspace(*cur))
break;

cur++;
}

while (end >= cur)
while (end > cur)
{
if (!isspace(*end))
break;

end--;
}

if (end >= cur)
res.assign(cur, end - cur + 1);
if (end > cur)
res.assign(cur, end - cur);
}

return res;
Expand Down

0 comments on commit 508bf97

Please sign in to comment.