]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Add simple fast-path to string.replace()
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 3 Nov 2016 18:31:28 +0000 (19:31 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 3 Nov 2016 19:47:24 +0000 (20:47 +0100)
vapi/glib-2.0.vapi

index dc9ffbedda7d0cc79e33df878f994e63f6118740..06cd9d7255b98f7af8702dc4f9dada8db5b16887 100644 (file)
@@ -1397,6 +1397,9 @@ public class string {
        }
 
        public string replace (string old, string replacement) {
+               if (*((char*) this) == '\0' || *((char*) old) == '\0' || old == replacement)
+                       return this;
+
                try {
                        var regex = new GLib.Regex (GLib.Regex.escape_string (old));
                        return regex.replace_literal (this, -1, 0, replacement);