From 079a326db3dc2bde594944a2bee7db4de2fce2a4 Mon Sep 17 00:00:00 2001 From: Patrick Reisert Date: Fri, 31 May 2019 21:10:07 +0200 Subject: [PATCH] Add some more #[inline] --- src/cominterfaces.rs | 13 +++++++------ src/comptr.rs | 1 + src/rt/mod.rs | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/cominterfaces.rs b/src/cominterfaces.rs index 2674097..c246f28 100644 --- a/src/cominterfaces.rs +++ b/src/cominterfaces.rs @@ -49,14 +49,15 @@ pub struct IUnknown(ComPtr); impl ComIid for IUnknown { #[inline] fn iid() -> &'static Guid { &IID_IUnknown } } impl ComInterfaceAbi for w::um::unknwnbase::IUnknown { type Vtbl = w::um::unknwnbase::IUnknownVtbl; + #[inline] fn get_vtbl(&self) -> *const Self::Vtbl { self.lpVtbl } } impl ComInterface for IUnknown { type TAbi = w::um::unknwnbase::IUnknown; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { IUnknown(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { IUnknown(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } impl IUnknown { @@ -80,8 +81,8 @@ pub struct IRestrictedErrorInfo(ComPtr &'static Guid { &IID_IRestrictedErrorInfo } } impl ComInterface for IRestrictedErrorInfo { type TAbi = ComAbi; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { IRestrictedErrorInfo(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { IRestrictedErrorInfo(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } DEFINE_IID!(IID_IAgileObject, 0x94EA2B94, 0xE9CC, 0x49E0, 0xC0, 0xFF, 0xEE, 0x64, 0xCA, 0x8F, 0x5B, 0x90); @@ -106,6 +107,6 @@ impl std::ops::DerefMut for IAgileObject { impl ComIid for IAgileObject { #[inline] fn iid() -> &'static Guid { &IID_IAgileObject } } impl ComInterface for IAgileObject { type TAbi = ComAbi; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { IAgileObject(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { IAgileObject(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } diff --git a/src/comptr.rs b/src/comptr.rs index f673084..4a41939 100644 --- a/src/comptr.rs +++ b/src/comptr.rs @@ -13,6 +13,7 @@ pub struct ComAbi { impl ComInterfaceAbi for ComAbi { type Vtbl = Vtbl; + #[inline] fn get_vtbl(&self) -> *const Vtbl { self.lpVtbl } diff --git a/src/rt/mod.rs b/src/rt/mod.rs index 7cf14b0..76b073f 100644 --- a/src/rt/mod.rs +++ b/src/rt/mod.rs @@ -313,8 +313,8 @@ macro_rules! RT_INTERFACE { } impl ComInterface for $interface { type TAbi = crate::comptr::ComAbi<$vtbl>; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } impl crate::RtType for $interface { type In = Self; @@ -362,8 +362,8 @@ macro_rules! RT_INTERFACE { } impl ComInterface for $interface { type TAbi = crate::comptr::ComAbi<$vtbl>; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } impl crate::RtType for $interface { type In = Self; @@ -408,8 +408,8 @@ macro_rules! RT_INTERFACE { pub struct $interface<$t1: RtType>(ComPtr>>); impl<$t1> ComInterface for $interface<$t1> where $t1: RtType { type TAbi = crate::comptr::ComAbi<$vtbl<$t1>>; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } impl<$t1> crate::RtType for $interface<$t1> where $t1: RtType{ type In = Self; @@ -453,8 +453,8 @@ macro_rules! RT_INTERFACE { pub struct $interface<$t1: RtType, $t2: RtType>(ComPtr>>); impl<$t1, $t2> ComInterface for $interface<$t1, $t2> where $t1: RtType, $t2: RtType { type TAbi = crate::comptr::ComAbi<$vtbl<$t1, $t2>>; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $interface(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } impl<$t1, $t2> crate::RtType for $interface<$t1, $t2> where $t1: RtType, $t2: RtType { type In = Self; @@ -634,8 +634,8 @@ macro_rules! RT_CLASS { unsafe impl crate::RtClassInterface for $cls {} impl ComInterface for $cls { type TAbi = <$interface as ComInterface>::TAbi; - unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $cls(ComPtr::wrap(ptr)) } - fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } + #[inline] unsafe fn wrap_com(ptr: *mut Self::TAbi) -> Self { $cls(ComPtr::wrap(ptr)) } + #[inline] fn get_abi(&self) -> &Self::TAbi { self.0.as_abi() } } impl ComIid for $cls { #[inline] fn iid() -> &'static crate::Guid { <$interface as ComIid>::iid() }