]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Computing length once is enough in string.to_utf8()/splice() 121c89e82e376dbed0959ef9e961ee4fd8bc8a4b
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 30 Oct 2018 08:00:01 +0000 (09:00 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 30 Oct 2018 09:04:11 +0000 (10:04 +0100)
vapi/glib-2.0.vapi

index e248f42beaa981673ea97ac0efbeb1378fd5cfe9..ce924a70a801d94e90ee66afc7a6f41ea751f595 100644 (file)
@@ -1455,7 +1455,7 @@ public class string {
                        str_size = ((!)(str)).length;
                }
 
-               string* result = GLib.malloc0 (this.length - (end - start) + str_size + 1);
+               string* result = GLib.malloc0 (string_length - (end - start) + str_size + 1);
 
                char* dest = (char*) result;
 
@@ -1503,9 +1503,10 @@ public class string {
        }
 
        public char[] to_utf8 () {
-               char[] result = new char[this.length + 1];
+               var string_length = this.length;
+               char[] result = new char[string_length + 1];
                result.length--;
-               GLib.Memory.copy (result, this, this.length);
+               GLib.Memory.copy (result, this, string_length);
                return result;
        }