summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2018-12-16 00:44:18 +0000
committerHein-Pieter van Braam <hp@tmm.cx>2018-12-16 16:51:38 +0100
commit4e25e5066bfd6a1ea9d5dbfa5db9e25b66b8aa02 (patch)
tree1d774f8ffe2f6321aa22bfe9148ddc24515ae8ba /modules/gdnative
parent7ac67bfec106d2ae807e845d0e093c6e0f2c43b5 (diff)
Reduce String CoW
By introducing an intermediate proxy class for the array subscript operator for String and CharString we can control better when CowData will actually CoW. This should improve performance of String usage for most cases.
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/gdnative/string.cpp2
-rw-r--r--modules/gdnative/gdnative_api.json2
-rw-r--r--modules/gdnative/include/gdnative/string.h2
3 files changed, 3 insertions, 3 deletions
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 0996633b70..c0c7ab5420 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -74,7 +74,7 @@ void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t
memnew_placement(dest, String(p_contents, p_size));
}
-wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) {
+const wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) {
String *self = (String *)p_self;
return &(self->operator[](p_idx));
}
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index c5a1fa139e..df7110f075 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -4755,7 +4755,7 @@
},
{
"name": "godot_string_operator_index",
- "return_type": "wchar_t *",
+ "return_type": "const wchar_t *",
"arguments": [
["godot_string *", "p_self"],
["const godot_int", "p_idx"]
diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h
index 95ae42a9ec..2ca9fd9e15 100644
--- a/modules/gdnative/include/gdnative/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -79,7 +79,7 @@ void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size);
-wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx);
+const wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx);
wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx);
const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self);