Directly dereference DebugCategory struct to read the threshold and #[inline]

This should improve logging performance if the threshold is not high
enough.
This commit is contained in:
Sebastian Dröge 2018-03-16 12:27:36 +02:00
parent c38af51bf0
commit fc7cda4522

View file

@ -102,6 +102,7 @@ impl DebugCategory {
} }
} }
#[inline]
pub fn log<O: IsA<::Object>>( pub fn log<O: IsA<::Object>>(
&self, &self,
obj: Option<&O>, obj: Option<&O>,
@ -111,9 +112,11 @@ impl DebugCategory {
line: u32, line: u32,
args: fmt::Arguments, args: fmt::Arguments,
) { ) {
if level.to_glib() as u32 > self.get_threshold().to_glib() as u32 { unsafe {
if level.to_glib() as i32 > (*self.0).threshold {
return; return;
} }
}
let obj_ptr = match obj { let obj_ptr = match obj {
Some(obj) => obj.to_glib_none().0 as *mut gobject_ffi::GObject, Some(obj) => obj.to_glib_none().0 as *mut gobject_ffi::GObject,