From a6b1e0a412a3c957d675b78982815826ec0f84d9 Mon Sep 17 00:00:00 2001 From: chyyran Date: Thu, 16 Feb 2023 18:23:56 -0500 Subject: [PATCH] capi: use unwrap_unchecked when we're certain a value is not null. --- librashader-capi/src/error.rs | 4 ++-- librashader-runtime-d3d12/src/samplers.rs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/librashader-capi/src/error.rs b/librashader-capi/src/error.rs index c56dfa0..78462c9 100644 --- a/librashader-capi/src/error.rs +++ b/librashader-capi/src/error.rs @@ -223,14 +223,14 @@ macro_rules! assert_some_ptr { return $crate::error::LibrashaderError::InvalidParameter(stringify!($value)).export(); } - let $value = unsafe { $value.as_ref().unwrap().as_ref() }; + let $value = unsafe { $value.as_ref().unwrap_unchecked().as_ref() }; }; (mut $value:ident) => { if $value.is_none() { return $crate::error::LibrashaderError::InvalidParameter(stringify!($value)).export(); } - let $value = unsafe { $value.as_mut().unwrap().as_mut() }; + let $value = unsafe { $value.as_mut().unwrap_unchecked().as_mut() }; }; } diff --git a/librashader-runtime-d3d12/src/samplers.rs b/librashader-runtime-d3d12/src/samplers.rs index cf5b9c4..f92ff99 100644 --- a/librashader-runtime-d3d12/src/samplers.rs +++ b/librashader-runtime-d3d12/src/samplers.rs @@ -1,4 +1,3 @@ -use std::iter::Filter; use crate::descriptor_heap::{D3D12DescriptorHeap, D3D12DescriptorHeapSlot, SamplerPaletteHeap}; use crate::error; use librashader_common::{FilterMode, WrapMode};