-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
Conversation
There was a problem hiding this 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.
xrGetInstanceProcAddr
callsxrGetInstanceProcAddr
calls
There was a problem hiding this 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
.
@@ -57,7 +57,7 @@ pub struct MultimodalMeta { | |||
|
|||
impl MultimodalMeta { | |||
pub fn new<G>( | |||
session: xr::Session<G>, | |||
session: &xr::Session<G>, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this 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!
No description provided.