From 3fb9c0e4fc7427354ec9a818dc87657a931a8fc6 Mon Sep 17 00:00:00 2001 From: kelpsyberry <138107494+kelpsyberry@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:08:22 +0200 Subject: [PATCH] Fix more warnings --- frontend/desktop/src/debug_views/common.rs | 16 ++++++++++++++++ frontend/desktop/src/debug_views/ds_rom_info.rs | 8 ++++---- frontend/desktop/src/debug_views/fs.rs | 6 +++--- frontend/desktop/src/main.rs | 1 - frontend/desktop/src/ui.rs | 4 ++-- frontend/desktop/src/utils.rs | 16 ---------------- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/frontend/desktop/src/debug_views/common.rs b/frontend/desktop/src/debug_views/common.rs index 96a2399..7ae845a 100644 --- a/frontend/desktop/src/debug_views/common.rs +++ b/frontend/desktop/src/debug_views/common.rs @@ -134,3 +134,19 @@ macro_rules! selectable_value { .build(); } } + +pub fn format_size(size: u32) -> String { + let log1024 = 31_u32.saturating_sub(size.leading_zeros()) / 10; + let unit = ["B", "KiB", "MiB", "GiB"][log1024 as usize]; + let amount = size as f64 / (1 << (log1024 * 10)) as f64; + format!("{amount:.2} {unit}") +} + +pub fn format_size_shift(shift: usize) -> String { + let units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; + if let Some(unit) = units.get(shift / 10) { + format!("{} {unit}, 2^{shift} B", 1 << (shift % 10)) + } else { + format!("2^{shift} B") + } +} diff --git a/frontend/desktop/src/debug_views/ds_rom_info.rs b/frontend/desktop/src/debug_views/ds_rom_info.rs index 21d4eb1..d05a778 100644 --- a/frontend/desktop/src/debug_views/ds_rom_info.rs +++ b/frontend/desktop/src/debug_views/ds_rom_info.rs @@ -1,8 +1,8 @@ -use super::{BaseView, SingletonView, StaticView}; -use crate::{ - ui::window::Window, - utils::{format_size, format_size_shift, icon_data_to_rgba8}, +use super::{ + common::{format_size, format_size_shift}, + BaseView, SingletonView, StaticView, }; +use crate::{ui::window::Window, utils::icon_data_to_rgba8}; use dust_core::{ cpu, ds_slot::rom::{ diff --git a/frontend/desktop/src/debug_views/fs.rs b/frontend/desktop/src/debug_views/fs.rs index 7b5223e..7ba3008 100644 --- a/frontend/desktop/src/debug_views/fs.rs +++ b/frontend/desktop/src/debug_views/fs.rs @@ -1,8 +1,8 @@ use super::{ - BaseView, InstanceableView, MessageView, MessageViewEmuState, MessageViewMessages, - MessageViewNotifications, + common::format_size, BaseView, InstanceableView, MessageView, MessageViewEmuState, + MessageViewMessages, MessageViewNotifications, }; -use crate::{ui::window::Window, utils::format_size}; +use crate::ui::window::Window; use dust_core::{cpu, ds_slot::rom::header::Header, emu::Emu, utils::mem_prelude::*}; use imgui::{TableColumnFlags, TableColumnSetup, TableFlags, TreeNodeFlags, TreeNodeId}; use imgui_memory_editor::MemoryEditor; diff --git a/frontend/desktop/src/main.rs b/frontend/desktop/src/main.rs index 83ca906..1dcd5f0 100644 --- a/frontend/desktop/src/main.rs +++ b/frontend/desktop/src/main.rs @@ -2,7 +2,6 @@ step_trait, new_uninit, slice_ptr_get, - slice_ptr_len, array_chunks, portable_simd, associated_type_defaults, diff --git a/frontend/desktop/src/ui.rs b/frontend/desktop/src/ui.rs index ef5e8a3..3bad701 100644 --- a/frontend/desktop/src/ui.rs +++ b/frontend/desktop/src/ui.rs @@ -665,10 +665,10 @@ impl UiState { }); } - fn stop_emu(&mut self, config: &mut Config, window: &mut window::Window) { + fn stop_emu(&mut self, config: &mut Config, _window: &mut window::Window) { if let Some(emu) = self.emu.take() { #[cfg(feature = "debug-views")] - self.debug_views.emu_stopped(window, &emu.to_emu); + self.debug_views.emu_stopped(_window, &emu.to_emu); emu.send_message(emu::Message::Stop); self.frame_tx = Some(emu.thread.join().expect("couldn't join emulation thread")); diff --git a/frontend/desktop/src/utils.rs b/frontend/desktop/src/utils.rs index 1c4464f..0c4af30 100644 --- a/frontend/desktop/src/utils.rs +++ b/frontend/desktop/src/utils.rs @@ -257,19 +257,3 @@ pub fn icon_data_to_rgba8( } rgba } - -pub fn format_size(size: u32) -> String { - let log1024 = 31_u32.saturating_sub(size.leading_zeros()) / 10; - let unit = ["B", "KiB", "MiB", "GiB"][log1024 as usize]; - let amount = size as f64 / (1 << (log1024 * 10)) as f64; - format!("{amount:.2} {unit}") -} - -pub fn format_size_shift(shift: usize) -> String { - let units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; - if let Some(unit) = units.get(shift / 10) { - format!("{} {unit}, 2^{shift} B", 1 << (shift % 10)) - } else { - format!("2^{shift} B") - } -}