migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
985 stars 55 forks source link

Packed: _const interface for subscript getters #468

Closed kevinw closed 2 months ago

kevinw commented 2 months ago

Building on #456 - the subscript get functions for PackedXYZArrays do not need writeable pointers from Godot.

This changeset, by using the _const versions of the packed array interface functions, can save memory allocations b/c the copy-on-write logic doesn't need to happen for read-only access.

(Some more performance work from my GodotVision profiling—hitting 90FPS is important there!)

kevinw commented 2 months ago

Also: there's a piece I'm missing here—it would be nice if you had a PackedVector3Array with 1000 elements, and calling map on it called through the gdinterface once, instead of 1000 times. But it's unclear to me where via Swift protocols that happens—I'm assuming it calls subscript get, but I'm not sure yet...

migueldeicaza commented 2 months ago

This is a lovely optimization, thank you so much for this contribution!