Compute needle length only once in utils_string_replace_all()

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5966 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Colomban Wendling 2011-09-28 19:49:45 +00:00
parent a89fcc2cc4
commit 0eadc9bd7b

View File

@ -1581,6 +1581,7 @@ guint utils_string_replace_all(GString *haystack, const gchar *needle, const gch
{
guint count = 0;
gint pos = 0;
gsize needle_length = strlen(needle);
while (1)
{
@ -1589,7 +1590,7 @@ guint utils_string_replace_all(GString *haystack, const gchar *needle, const gch
if (pos == -1)
break;
pos = utils_string_replace(haystack, pos, strlen(needle), replace);
pos = utils_string_replace(haystack, pos, needle_length, replace);
count++;
}
return count;