[vala/wip/housekeeping: 1/4] glib-2.0: Add simple fast-path to string.replace()



commit a52298979c5248bbd153bb1a26aad5f414b748d0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Nov 3 19:31:28 2016 +0100

    glib-2.0: Add simple fast-path to string.replace()

 vapi/glib-2.0.vapi |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index dc9ffbe..39e55ed 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -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);


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