[vala/staging: 1/10] glib-2.0: Add simple fast-path to string.replace()



commit c644e6ca428c36402dbe3c5d1c27788acfe5b3cb
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..06cd9d7 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]