From 7fcd2f0cf606d8bf55f5e3672e7c8f86e140c418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 6 Dec 2022 10:06:59 +0200 Subject: [PATCH] gstreamer: Directly use fields for `DebugCategory` getters This allows for better optimizations as it doesn't go through an opaque FFI function. Part-of: --- gstreamer/src/log.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index 3e10bbed9..0b1bc4687 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -95,7 +95,7 @@ impl DebugCategory { #[doc(alias = "gst_debug_category_get_threshold")] pub fn threshold(self) -> crate::DebugLevel { match self.0 { - Some(cat) => unsafe { from_glib(ffi::gst_debug_category_get_threshold(cat.as_ptr())) }, + Some(cat) => unsafe { from_glib(cat.as_ref().threshold) }, None => crate::DebugLevel::None, } } @@ -118,7 +118,7 @@ impl DebugCategory { #[doc(alias = "gst_debug_category_get_color")] pub fn color(self) -> crate::DebugColorFlags { match self.0 { - Some(cat) => unsafe { from_glib(ffi::gst_debug_category_get_color(cat.as_ptr())) }, + Some(cat) => unsafe { from_glib(cat.as_ref().color) }, None => crate::DebugColorFlags::empty(), } } @@ -127,11 +127,7 @@ impl DebugCategory { #[doc(alias = "gst_debug_category_get_name")] pub fn name<'a>(self) -> &'a str { match self.0 { - Some(cat) => unsafe { - CStr::from_ptr(ffi::gst_debug_category_get_name(cat.as_ptr())) - .to_str() - .unwrap() - }, + Some(cat) => unsafe { CStr::from_ptr(cat.as_ref().name).to_str().unwrap() }, None => "", } } @@ -142,7 +138,7 @@ impl DebugCategory { let cat = self.0?; unsafe { - let ptr = ffi::gst_debug_category_get_description(cat.as_ptr()); + let ptr = cat.as_ref().description; if ptr.is_null() { None