Skip to content

Commit

Permalink
Fix ReplaceInString not appending the rest when needle is not found a…
Browse files Browse the repository at this point in the history
…nymore
  • Loading branch information
maxmitti committed Aug 15, 2024
1 parent 366940d commit 69a457e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/C4Strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,13 @@ std::basic_string<Char, Traits> ReplaceInString(std::basic_string_view<Char, Tra
std::size_t previousPos{0};
std::size_t pos{0};

string.find(needle);

for (;;)
{
previousPos = pos;
pos = string.find(needle, pos);
if (pos == decltype(string)::npos)
{
result.append(string, previousPos);
return result;
}

Expand Down

0 comments on commit 69a457e

Please sign in to comment.