Skip to content

Conversation

@Bromeon
Copy link
Member

@Bromeon Bromeon commented Sep 16, 2024

Enables several builtins that don't implement Copy to be passed by reference (borrowed) into engine APIs. Examples are Array, Packed*Array, Dictionary, Variant.

This lays the groundwork for future optimizations which exploit borrowing to avoid unnecessary cloning/ref-count operations, thus further reducing API call overhead.

There are some ergonomic impacts of requiring & in more places, however on the other side .clone() calls can often be avoided now. The current draft uses the Borrow trait in a few manual APIs to enable both by-value and by-ref; I'd probably use something else that uses by-value for Copy types and by-ref otherwise.

@Bromeon Bromeon added feature Adds functionality to the library c: ffi Low-level components and interaction with GDExtension API c: engine Godot classes (nodes, resources, ...) labels Sep 16, 2024
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-900

@Bromeon Bromeon added the breaking-change Requires SemVer bump label Sep 17, 2024
@Bromeon Bromeon added this to the 0.2 milestone Sep 18, 2024
@Bromeon Bromeon marked this pull request as ready for review September 18, 2024 19:34
@Bromeon Bromeon force-pushed the qol/engine-pass-by-ref branch from f1cfa06 to 2a13c68 Compare September 18, 2024 19:50
@Bromeon Bromeon force-pushed the qol/engine-pass-by-ref branch from 2a13c68 to 5a626c5 Compare September 18, 2024 19:54
@Bromeon Bromeon changed the title Pass-by-ref for non-Copy builtins Pass-by-ref for non-Copy builtins (frontend) Sep 18, 2024
@Bromeon
Copy link
Member Author

Bromeon commented Sep 18, 2024

Merging, as there's a sizeable amount of changes already. The "backend" changes (actual FFI passing) as well as fine-tuning the APIs like impl Borrow<T> can be done in separate PRs.

@Bromeon Bromeon added this pull request to the merge queue Sep 18, 2024
Merged via the queue into master with commit f33fe1f Sep 18, 2024
@Bromeon Bromeon deleted the qol/engine-pass-by-ref branch September 18, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Requires SemVer bump c: engine Godot classes (nodes, resources, ...) c: ffi Low-level components and interaction with GDExtension API feature Adds functionality to the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants