[epiphany] lib: Use g_string_replace() internally



commit 82ea6819d6c9f06f946236921924b839e78fd75c
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Tue Feb 22 13:55:30 2022 -0800

    lib: Use g_string_replace() internally
    
    This should introduce no functional changes.

 lib/ephy-string.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
---
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index dd434e1b8..73e854c93 100644
--- a/lib/ephy-string.c
+++ b/lib/ephy-string.c
@@ -244,23 +244,13 @@ ephy_string_find_and_replace (const char *haystack,
                               const char *to_repl)
 {
   GString *str;
-  const char *tmp;
-  gsize to_find_len;
-  gsize pos;
 
   g_assert (haystack);
   g_assert (to_find);
   g_assert (to_repl);
 
   str = g_string_new (haystack);
-  to_find_len = strlen (to_find);
-
-  while ((tmp = strstr (str->str, to_find)) != NULL) {
-    pos = tmp - str->str;
-    g_string_erase (str, pos, to_find_len);
-    g_string_insert (str, pos, to_repl);
-  }
-
+  g_string_replace (str, to_find, to_repl, 0);
   return g_string_free (str, FALSE);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]