diff --git a/core/string/ustring.h b/core/string/ustring.h index 46dea6574d..7ecf130879 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -171,10 +171,9 @@ public: _FORCE_INLINE_ CharProxy operator[](int p_index) { return CharProxy(p_index, _cowdata); } _FORCE_INLINE_ Char16String() {} - _FORCE_INLINE_ Char16String(const Char16String &p_str) { _cowdata._ref(p_str._cowdata); } - _FORCE_INLINE_ Char16String(Char16String &&p_str) : - _cowdata(std::move(p_str._cowdata)) {} - _FORCE_INLINE_ void operator=(const Char16String &p_str) { _cowdata._ref(p_str._cowdata); } + _FORCE_INLINE_ Char16String(const Char16String &p_str) = default; + _FORCE_INLINE_ Char16String(Char16String &&p_str) = default; + _FORCE_INLINE_ void operator=(const Char16String &p_str) { _cowdata = p_str._cowdata; } _FORCE_INLINE_ void operator=(Char16String &&p_str) { _cowdata = std::move(p_str._cowdata); } _FORCE_INLINE_ Char16String(const char16_t *p_cstr) { copy_from(p_cstr); } @@ -218,10 +217,9 @@ public: _FORCE_INLINE_ CharProxy operator[](int p_index) { return CharProxy(p_index, _cowdata); } _FORCE_INLINE_ CharString() {} - _FORCE_INLINE_ CharString(const CharString &p_str) { _cowdata._ref(p_str._cowdata); } - _FORCE_INLINE_ CharString(CharString &&p_str) : - _cowdata(std::move(p_str._cowdata)) {} - _FORCE_INLINE_ void operator=(const CharString &p_str) { _cowdata._ref(p_str._cowdata); } + _FORCE_INLINE_ CharString(const CharString &p_str) = default; + _FORCE_INLINE_ CharString(CharString &&p_str) = default; + _FORCE_INLINE_ void operator=(const CharString &p_str) { _cowdata = p_str._cowdata; } _FORCE_INLINE_ void operator=(CharString &&p_str) { _cowdata = std::move(p_str._cowdata); } _FORCE_INLINE_ CharString(const char *p_cstr) { copy_from(p_cstr); } @@ -609,13 +607,12 @@ public: */ _FORCE_INLINE_ String() {} - _FORCE_INLINE_ String(const String &p_str) { _cowdata._ref(p_str._cowdata); } - _FORCE_INLINE_ String(String &&p_str) : - _cowdata(std::move(p_str._cowdata)) {} + _FORCE_INLINE_ String(const String &p_str) = default; + _FORCE_INLINE_ String(String &&p_str) = default; #ifdef SIZE_EXTRA _NO_INLINE_ ~String() {} #endif - _FORCE_INLINE_ void operator=(const String &p_str) { _cowdata._ref(p_str._cowdata); } + _FORCE_INLINE_ void operator=(const String &p_str) { _cowdata = p_str._cowdata; } _FORCE_INLINE_ void operator=(String &&p_str) { _cowdata = std::move(p_str._cowdata); } Vector to_ascii_buffer() const; diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h index f4a7211be7..4cdf1f35db 100644 --- a/core/templates/cowdata.h +++ b/core/templates/cowdata.h @@ -39,28 +39,12 @@ #include #include -template -class Vector; -class String; -class Char16String; -class CharString; -template -class VMap; - static_assert(std::is_trivially_destructible_v>); GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wplacement-new") // Silence a false positive warning (see GH-52119). template class CowData { - template - friend class Vector; - friend class String; - friend class Char16String; - friend class CharString; - template - friend class VMap; - public: typedef int64_t Size; typedef uint64_t USize; @@ -129,11 +113,11 @@ private: return (USize *)((uint8_t *)_ptr - DATA_OFFSET + SIZE_OFFSET); } - _FORCE_INLINE_ USize _get_alloc_size(USize p_elements) const { + _FORCE_INLINE_ static USize _get_alloc_size(USize p_elements) { return next_po2(p_elements * sizeof(T)); } - _FORCE_INLINE_ bool _get_alloc_size_checked(USize p_elements, USize *out) const { + _FORCE_INLINE_ static bool _get_alloc_size_checked(USize p_elements, USize *out) { if (unlikely(p_elements == 0)) { *out = 0; return true; diff --git a/core/templates/vector.h b/core/templates/vector.h index 02c86ce8a8..f30747d238 100644 --- a/core/templates/vector.h +++ b/core/templates/vector.h @@ -45,6 +45,9 @@ #include +template +class Vector; + template class VectorWriteProxy { public: @@ -167,7 +170,7 @@ public: insert(i, p_val); } - void operator=(const Vector &p_from) { _cowdata._ref(p_from._cowdata); } + void operator=(const Vector &p_from) { _cowdata = p_from._cowdata; } void operator=(Vector &&p_from) { _cowdata = std::move(p_from._cowdata); } Vector to_byte_array() const { @@ -304,9 +307,8 @@ public: _FORCE_INLINE_ Vector() {} _FORCE_INLINE_ Vector(std::initializer_list p_init) : _cowdata(p_init) {} - _FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); } - _FORCE_INLINE_ Vector(Vector &&p_from) : - _cowdata(std::move(p_from._cowdata)) {} + _FORCE_INLINE_ Vector(const Vector &p_from) = default; + _FORCE_INLINE_ Vector(Vector &&p_from) = default; _FORCE_INLINE_ ~Vector() {} }; diff --git a/core/templates/vmap.h b/core/templates/vmap.h index ae922f0bb3..be325ee336 100644 --- a/core/templates/vmap.h +++ b/core/templates/vmap.h @@ -195,9 +195,7 @@ public: _FORCE_INLINE_ VMap() {} _FORCE_INLINE_ VMap(std::initializer_list p_init) : _cowdata(p_init) {} - _FORCE_INLINE_ VMap(const VMap &p_from) { _cowdata._ref(p_from._cowdata); } + _FORCE_INLINE_ VMap(const VMap &p_from) = default; - inline void operator=(const VMap &p_from) { - _cowdata._ref(p_from._cowdata); - } + void operator=(const VMap &p_from) { _cowdata = p_from._cowdata; } }; diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 103400babb..c300867c5f 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -38,6 +38,9 @@ class VisualShaderNodeParameter; class VisualShaderNode; +template +class VMap; + class VisualShader : public Shader { GDCLASS(VisualShader, Shader);