summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-01-26 00:27:08 +0100
committerGitHub <noreply@github.com>2021-01-26 00:27:08 +0100
commit3d1dd195d40de30631f0cb7b6f485da290dee5c6 (patch)
tree488e2ada984bbaa0401851383294479e413a9276 /doc
parent78661d1a4395d209a9aa4e30b53a988aec140a30 (diff)
parent7ce3cc0478261fb39344c98551cadab3ccb6265b (diff)
Merge pull request #45458 from Calinou/doc-array-push-pop-front-performance
Document low performance of `Array.push_front()` and `Array.pop_front()`
Diffstat (limited to 'doc')
-rw-r--r--doc/classes/Array.xml20
1 files changed, 14 insertions, 6 deletions
diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml
index db5d377c62..909380b3b2 100644
--- a/doc/classes/Array.xml
+++ b/doc/classes/Array.xml
@@ -234,7 +234,9 @@
<argument index="0" name="value" type="Variant">
</argument>
<description>
- Removes the first occurrence of a value from the array.
+ Removes the first occurrence of a value from the array. To remove an element by index, use [method remove] instead.
+ [b]Note:[/b] This method acts in-place and doesn't return a value.
+ [b]Note:[/b] On large arrays, this method will be slower if the removed element is close to the beginning of the array (index 0). This is because all elements placed after the removed element have to be reindexed.
</description>
</method>
<method name="find">
@@ -323,6 +325,8 @@
</argument>
<description>
Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]pos == size()[/code]).
+ [b]Note:[/b] This method acts in-place and doesn't return a value.
+ [b]Note:[/b] On large arrays, this method will be slower if the inserted element is close to the beginning of the array (index 0). This is because all elements placed after the newly inserted element have to be reindexed.
</description>
</method>
<method name="invert">
@@ -421,14 +425,15 @@
<return type="Variant">
</return>
<description>
- Removes and returns the last element of the array. Returns [code]null[/code] if the array is empty, without printing an error message.
+ Removes and returns the last element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. See also [method pop_front].
</description>
</method>
<method name="pop_front">
<return type="Variant">
</return>
<description>
- Removes and returns the first element of the array. Returns [code]null[/code] if the array is empty, without printing an error message.
+ Removes and returns the first element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. See also [method pop_back].
+ [b]Note:[/b] On large arrays, this method is much slower than [method pop_back] as it will reindex all the array's elements every time it's called. The larger the array, the slower [method pop_front] will be.
</description>
</method>
<method name="push_back">
@@ -437,7 +442,7 @@
<argument index="0" name="value" type="Variant">
</argument>
<description>
- Appends an element at the end of the array.
+ Appends an element at the end of the array. See also [method push_front].
</description>
</method>
<method name="push_front">
@@ -446,7 +451,8 @@
<argument index="0" name="value" type="Variant">
</argument>
<description>
- Adds an element at the beginning of the array.
+ Adds an element at the beginning of the array. See also [method push_back].
+ [b]Note:[/b] On large arrays, this method is much slower than [method push_back] as it will reindex all the array's elements every time it's called. The larger the array, the slower [method push_front] will be.
</description>
</method>
<method name="remove">
@@ -455,7 +461,9 @@
<argument index="0" name="position" type="int">
</argument>
<description>
- Removes an element from the array by index. If the index does not exist in the array, nothing happens.
+ Removes an element from the array by index. If the index does not exist in the array, nothing happens. To remove an element by searching for its value, use [method erase] instead.
+ [b]Note:[/b] This method acts in-place and doesn't return a value.
+ [b]Note:[/b] On large arrays, this method will be slower if the removed element is close to the beginning of the array (index 0). This is because all elements placed after the removed element have to be reindexed.
</description>
</method>
<method name="resize">