Skip to content

Commit 98ce9b5

Browse files
committed
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.
1 parent e66144f commit 98ce9b5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

contributing/development/core_and_modules/core_types.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,18 @@ which are equivalent to new, delete, new[] and delete[].
103103
memnew/memdelete also use a little C++ magic and notify Objects right
104104
after they are created, and right before they are deleted.
105105

106-
For dynamic memory, use Vector<>.
106+
For dynamic memory, use Godot's ``Vector<>`` or one of its variations.
107+
Godot's ``Vector<>`` behaves much like an STL ``Vector<>``, but is simpler,
108+
thread safe, and uses Copy-On-Write semantics.
109+
It can be safely passed via public API.
110+
111+
The ``Packed*Array`` :ref:`types <doc_gdscript_packed_arrays>` are aliases for
112+
specific ``Vector<*>`` types (e.g., ``PackedByteArray``, ``PackedInt32Array``)
113+
that are accessible via GDScript. Prefer using the ``Packed*Array`` aliases
114+
when available.
115+
116+
``LocalVector<>`` is a non-COW version, with less overhead. It is intended for
117+
internal use where the benefits of COW are not needed.
107118

108119
References:
109120
~~~~~~~~~~~

tutorials/scripting/gdscript/gdscript_basics.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ native or user class, or enum. Nested array types (like ``Array[Array[int]]``) a
890890
The only exception was made for the ``Array`` (``Array[Variant]``) type, for user convenience
891891
and compatibility with old code. However, operations on untyped arrays are considered unsafe.
892892

893+
.. _doc_gdscript_packed_arrays:
894+
893895
Packed arrays
894896
^^^^^^^^^^^^^
895897

0 commit comments

Comments
 (0)