Skip to content

Commit 56555c7

Browse files
committed
Edit "Core types" descriptions of Pair (mention KeyValue), RBMap (discourage its use), Span (make it's clear it's low level API), and String (clarify UTF-32 motivation).
1 parent e8e6a57 commit 56555c7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

engine_details/architecture/core_types.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ scripting API.
142142
| Godot datatype | Closest C++ STL datatype | Comment |
143143
+=======================+==========================+=======================================================================================+
144144
| |string| 📜 | ``std::string`` | **Use this as the "default" string type.** ``String`` uses UTF-32 encoding |
145-
| | | to improve performance thanks to its fixed character size. |
145+
| | | to simplify processing thanks to its fixed character size. |
146146
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
147147
| |vector| | ``std::vector`` | **Use this as the "default" vector type.** Uses copy-on-write (COW) semantics. |
148148
| | | This means it's generally slower but can be copied around almost for free. |
@@ -180,8 +180,10 @@ scripting API.
180180
| | | no heap allocations. |
181181
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
182182
| |span| | ``std::span`` | Represents read-only access to a contiguous array without needing to copy any data. |
183-
| | | See `pull request description <https://github.com/godotengine/godot/pull/100293>`__ |
184-
| | | for details. |
183+
| | | Note that ``Span`` is designed to be a high performance API: It does not perform |
184+
| | | parameter correctness checks in the same way you might be used to with other Godot |
185+
| | | containers. Use with care. |
186+
| | | `Span` can be constructed from most array-like containers (e.g. ``vector.span()``). |
185187
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
186188
| |rb_set| | ``std::set`` | Uses a `red-black tree <https://en.wikipedia.org/wiki/Red-black_tree>`__ |
187189
| | | for faster access. |
@@ -195,16 +197,18 @@ scripting API.
195197
| | | Use this map type when either of these affordances are needed. Use ``AHashMap`` |
196198
| | | otherwise. |
197199
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
198-
| |rb_map| | ``std::map`` | Uses a `red-black tree <https://en.wikipedia.org/wiki/Red-black-tree>`__ |
199-
| | | for faster access. |
200+
| |rb_map| | ``std::map`` | Map type that uses a |
201+
| | | `red-black tree <https://en.wikipedia.org/wiki/Red-black-tree>`__ to find keys. |
202+
| | | The performance benefits of ``RBMap`` aren't established, so prefer using other types.|
200203
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
201204
| |dictionary| 📜 | ``std::unordered_map`` | Keys and values can be of any Variant type. No static typing is imposed. |
202205
| | | Uses shared reference counting, similar to ``std::shared_ptr``. |
203206
| | | Preserves insertion order. Uses ``HashMap<Variant>`` internally. |
204207
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
205208
| |typed_dictionary| 📜 | ``std::unordered_map`` | Subclass of ``Dictionary`` but with static typing for its keys and values. |
206209
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
207-
| |pair| | ``std::pair`` | Stores a single key-value pair. |
210+
| |pair| | ``std::pair`` | Stores a single pair. See also ``KeyValue`` in the same file, which uses read-only |
211+
| | | keys. |
208212
+-----------------------+--------------------------+---------------------------------------------------------------------------------------+
209213

210214
.. |string| replace:: `String <https://github.com/godotengine/godot/blob/master/core/string/ustring.h>`__

0 commit comments

Comments
 (0)