Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark wrapper functions inline #107

Open
VoilaNeighbor opened this issue Sep 2, 2023 · 2 comments
Open

Mark wrapper functions inline #107

VoilaNeighbor opened this issue Sep 2, 2023 · 2 comments

Comments

@VoilaNeighbor
Copy link

VoilaNeighbor commented Sep 2, 2023

Zig has well-defined return copy elision. If we define the wrapper functions to be inline, then many copies from a semantical view would be eliminated. For example:

pub fn getPhysicalDeviceProperties(
    self: Self,
    physical_device: PhysicalDevice,
) callconv(.Inline) PhysicalDeviceProperties {
    var properties: PhysicalDeviceProperties = undefined;
    self.dispatch.vkGetPhysicalDeviceProperties(
        physical_device,
        &properties,
    );
    return properties;
}
@Snektron
Copy link
Owner

Wow sorry, I completely missed this issue. Considering that this is mostly just a light-weight wrapper, I think there is no downside into making these function inline (there shouldn't be too much extra processing time).

@VoilaNeighbor
Copy link
Author

I was new to Zig. Lately I found that we could just write pub inline fn, simpler than my original proposal

@Snektron Snektron added this to the Spring cleaning 2024 milestone Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants