Skip to content

Commit

Permalink
Simplify the compare_descriptors implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
vladbat00 committed Nov 5, 2023
1 parent daeb638 commit 887422c
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use bevy::{
utils::HashMap,
window::{PrimaryWindow, Window},
};
use std::{borrow::Cow, mem::discriminant};
use std::borrow::Cow;
#[cfg(all(feature = "manage_clipboard", not(target_arch = "wasm32")))]
use std::cell::{RefCell, RefMut};
#[cfg(all(feature = "manage_clipboard", not(target_arch = "wasm32")))]
Expand Down Expand Up @@ -143,18 +143,8 @@ impl PartialEq for EguiSettings {
fn compare_descriptors(a: &ImageSampler, b: &ImageSampler) -> bool {
match (a, b) {
(ImageSampler::Default, ImageSampler::Default) => true,
(ImageSampler::Descriptor(a), ImageSampler::Descriptor(b)) => {
a.label == b.label
&& discriminant(&a.address_mode_u) == discriminant(&b.address_mode_u)
&& discriminant(&a.address_mode_v) == discriminant(&b.address_mode_v)
&& discriminant(&a.address_mode_w) == discriminant(&b.address_mode_w)
&& discriminant(&a.mag_filter) == discriminant(&b.mag_filter)
&& discriminant(&a.min_filter) == discriminant(&b.min_filter)
&& discriminant(&a.mipmap_filter) == discriminant(&b.mipmap_filter)
&& a.lod_min_clamp == b.lod_min_clamp
&& a.lod_max_clamp == b.lod_max_clamp
&& a.anisotropy_clamp == b.anisotropy_clamp
&& discriminant(&a.border_color) == discriminant(&b.border_color)
(ImageSampler::Descriptor(descriptor_a), ImageSampler::Descriptor(descriptor_b)) => {
descriptor_a.as_wgpu() == descriptor_b.as_wgpu()
}
_ => false,
}
Expand Down

0 comments on commit 887422c

Please sign in to comment.