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

refactor: Function for xrGetInstanceProcAddr calls #2683

Merged
merged 4 commits into from
Feb 2, 2025

Conversation

curoviyxru
Copy link
Contributor

No description provided.

Copy link
Member

@zmerp zmerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make a few changes. instead of a macro, use a normal function. Move the function at extra_extensions/mod.rs. For the function name, use a simple string parameter, and pass the xr prefix always, not worth trying to adding it back inside the function. Another thing, add inside the function .ok_or(sys::Result::ERROR_EXTENSION_NOT_PRESENT) and make it return xr::Result. then you just use the ? operator on the caller site.

@curoviyxru curoviyxru changed the title refactor: Macro for xrGetInstanceProcAddr calls refactor: Function for xrGetInstanceProcAddr calls Feb 2, 2025
Copy link
Member

@zmerp zmerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but I forgot to mention one last nit, to make it even more concise you could pass &Session directly instead of &Instance.

@curoviyxru curoviyxru requested a review from zmerp February 2, 2025 21:06
@@ -57,7 +57,7 @@ pub struct MultimodalMeta {

impl MultimodalMeta {
pub fn new<G>(
session: xr::Session<G>,
session: &xr::Session<G>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well almost good, but going full nitpicky, i say you should not use a reference here since later in this function you have to call to_owned(). Same for FaceTrackerPico::new(). Maybe I should have been more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so as I understand, I should avoid to_owned() and clone value beforehand instead if I need to move it?

Copy link
Member

@zmerp zmerp Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you need to move the value, use a move parameter. if you need only references, then you use a reference parameter. it's better to always require to the caller any copies. This is for MultimodalMeta::new() and FaceTrackerPico::new(). I would make an exception maybe for functions called multiple times made to abstract common code AND they are not in a critical path, where I would use a reference regardless (like get_instance_proc, but actually this function doesn't need to own the Session so it doesn't matter)

@curoviyxru curoviyxru requested a review from zmerp February 2, 2025 21:29
Copy link
Member

@zmerp zmerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, thanks!

@zmerp zmerp merged commit bfbad44 into alvr-org:master Feb 2, 2025
8 checks passed
@curoviyxru curoviyxru deleted the get-instance-proc branch February 2, 2025 23:10
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

Successfully merging this pull request may close these issues.

2 participants