瀏覽代碼

Merge pull request #84666 from MewPurPur/document-resize-performance

Add performance note to `Array.resize()`
Rémi Verschelde 1 年之前
父節點
當前提交
574e076f51

+ 1 - 0
doc/classes/Array.xml

@@ -544,6 +544,7 @@
 			<param index="0" name="size" type="int" />
 			<description>
 				Resizes the array to contain a different number of elements. If the array size is smaller, elements are cleared, if bigger, new elements are [code]null[/code]. Returns [constant OK] on success, or one of the other [enum Error] values if the operation failed.
+				Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 				[b]Note:[/b] This method acts in-place and doesn't return a modified array.
 			</description>
 		</method>

+ 1 - 1
doc/classes/PackedByteArray.xml

@@ -397,7 +397,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedColorArray.xml

@@ -131,7 +131,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedFloat32Array.xml

@@ -132,7 +132,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedFloat64Array.xml

@@ -132,7 +132,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedInt32Array.xml

@@ -128,7 +128,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedInt64Array.xml

@@ -128,7 +128,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedStringArray.xml

@@ -134,7 +134,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedVector2Array.xml

@@ -136,7 +136,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">

+ 1 - 1
doc/classes/PackedVector3Array.xml

@@ -135,7 +135,7 @@
 			<return type="int" />
 			<param index="0" name="new_size" type="int" />
 			<description>
-				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
+				Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling [method resize] once and assigning the new values is faster than adding new elements one by one.
 			</description>
 		</method>
 		<method name="reverse">