Document low performance of Array.push_front() and Array.pop_front()

(cherry picked from commit 7ce3cc0478)
This commit is contained in:
Hugo Locurcio 2021-01-25 21:14:30 +01:00 committed by Rémi Verschelde
parent af891cebe4
commit e2a2005a48
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -181,7 +181,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">
@ -247,6 +249,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">
@ -272,35 +276,39 @@
<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">
<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">
<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">
<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">