From 98ce9b570baf0cbdba859048b2523aa69209590f Mon Sep 17 00:00:00 2001 From: Sai Nane Date: Wed, 4 Dec 2024 05:57:38 +0000 Subject: [PATCH] Briefly document Vector<> variations `Packed*Array` aliases seem universally preferred where available, so a link to the list of types seems appropriate. `LocalVector` is used sparingly, so mentioning the intent and rough tradeoff involved seems right for an overview. --- .../development/core_and_modules/core_types.rst | 13 ++++++++++++- tutorials/scripting/gdscript/gdscript_basics.rst | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contributing/development/core_and_modules/core_types.rst b/contributing/development/core_and_modules/core_types.rst index 4d5d15544..92251de01 100644 --- a/contributing/development/core_and_modules/core_types.rst +++ b/contributing/development/core_and_modules/core_types.rst @@ -103,7 +103,18 @@ which are equivalent to new, delete, new[] and delete[]. memnew/memdelete also use a little C++ magic and notify Objects right after they are created, and right before they are deleted. -For dynamic memory, use Vector<>. +For dynamic memory, use Godot's ``Vector<>`` or one of its variations. +Godot's ``Vector<>`` behaves much like an STL ``Vector<>``, but is simpler, +thread safe, and uses Copy-On-Write semantics. +It can be safely passed via public API. + +The ``Packed*Array`` :ref:`types ` are aliases for +specific ``Vector<*>`` types (e.g., ``PackedByteArray``, ``PackedInt32Array``) +that are accessible via GDScript. Prefer using the ``Packed*Array`` aliases +when available. + +``LocalVector<>`` is a non-COW version, with less overhead. It is intended for +internal use where the benefits of COW are not needed. References: ~~~~~~~~~~~ diff --git a/tutorials/scripting/gdscript/gdscript_basics.rst b/tutorials/scripting/gdscript/gdscript_basics.rst index c80c09aca..60fa034df 100644 --- a/tutorials/scripting/gdscript/gdscript_basics.rst +++ b/tutorials/scripting/gdscript/gdscript_basics.rst @@ -890,6 +890,8 @@ native or user class, or enum. Nested array types (like ``Array[Array[int]]``) a The only exception was made for the ``Array`` (``Array[Variant]``) type, for user convenience and compatibility with old code. However, operations on untyped arrays are considered unsafe. +.. _doc_gdscript_packed_arrays: + Packed arrays ^^^^^^^^^^^^^