[vala/0.36] glib-2.0: Computing length once is enough in string.to_utf8()/splice()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] glib-2.0: Computing length once is enough in string.to_utf8()/splice()
- Date: Tue, 30 Oct 2018 11:33:10 +0000 (UTC)
commit 7d5fa9bab51d4175d7e8f24367f6602c2c7cd7dc
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Oct 30 09:00:01 2018 +0100
glib-2.0: Computing length once is enough in string.to_utf8()/splice()
vapi/glib-2.0.vapi | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 813a35083..602693927 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -1385,7 +1385,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;
@@ -1433,9 +1433,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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]