Skip to content

Commit

Permalink
Fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kelpsyberry committed Apr 14, 2024
1 parent 5335936 commit 3fb9c0e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
16 changes: 16 additions & 0 deletions frontend/desktop/src/debug_views/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
8 changes: 4 additions & 4 deletions frontend/desktop/src/debug_views/ds_rom_info.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
6 changes: 3 additions & 3 deletions frontend/desktop/src/debug_views/fs.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion frontend/desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
step_trait,
new_uninit,
slice_ptr_get,
slice_ptr_len,
array_chunks,
portable_simd,
associated_type_defaults,
Expand Down
4 changes: 2 additions & 2 deletions frontend/desktop/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
16 changes: 0 additions & 16 deletions frontend/desktop/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit 3fb9c0e

Please sign in to comment.