TODO: this O(n^2) in #occurences of find, due to repeated copying.
*/
string &
-replace_all (string &str, string find, string replace)
+replace_all (string *str, string const &find, string const &replace)
{
ssize len = find.length ();
- for (ssize i = str.find (find); i != NPOS; i = str.find (find, i + len))
- str = str.replace (i, len, replace);
- return str;
+ for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + len))
+ *str = str->replace (i, len, replace);
+ return *str;
}
string &
-replace_all (string &str, char find, char replace)
+replace_all (string *str, char find, char replace)
{
- for (ssize i = str.find (find); i != NPOS; i = str.find (find, i + 1))
- str[i] = replace;
- return str;
+ for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + 1))
+ (*str)[i] = replace;
+ return *str;
}
char *