Remove Packed Arrays in favor of Statically Typed Arrays #6505
Replies: 3 comments 5 replies
-
Not sure, but probably not the best idea given those structures are often used in context of network communication |
Beta Was this translation helpful? Give feedback.
-
Unless it would just be syntactic sugar it would impact performance and usability, even ignoring the limitations of removing the sized int and float arrays |
Beta Was this translation helpful? Give feedback.
-
The main difference between the two is that packed array are "passed by value" using copy-on-write logic. This allows, for example, for a node to pass a PackedVector2Array to the RenderingServer via some method call, and, immediately after, modify the array and use it for something else, without causing errors in rendering. The RenderingServer is guaranteed that the version it got is non-mutable from the outside. And vice versa. If the RenderingServer modifies the array somehow, it doesn't effect the caller. This is particularly important for arrays used as long-term cache, to prevent cache corruption. Typed array don't have that property. If you pass a typed array, it's passed by reference, and is mutable. The data inside it can be corrupted by both caller and callee. It doesn't and can't provide the same guarantees as a packed array. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am not sure about the scale or even possibility of this. This is just something I wanted to bring up in case there is any interest.
Remove the 9 PackedArray classes in favor of simply using
var arr: Array[type]
as introduced in Godot 4. Tightly packed memory functionality would be moved into it.Potential regressions:
Beta Was this translation helpful? Give feedback.
All reactions