diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2022-09-18 00:09:49 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2022-09-19 15:18:25 +0300 |
commit | a7a50d3078cb7466ab341ddfc30a80c7b1f8dfdb (patch) | |
tree | 7e84d36b322f380e91c8c71020cfba283e0ff929 | |
parent | b138d9bc6166b763febf035b50109d810e3c18c9 (diff) | |
download | meli-a7a50d3078cb7466ab341ddfc30a80c7b1f8dfdb.zip |
src/: Box<_> some large fields in biggest types
As reported by `cargo +nightly typesize`
-rw-r--r-- | src/components/mail/listing.rs | 4 | ||||
-rw-r--r-- | src/components/mail/listing/compact.rs | 10 | ||||
-rw-r--r-- | src/components/mail/listing/thread.rs | 6 | ||||
-rw-r--r-- | src/state.rs | 24 | ||||
-rw-r--r-- | src/terminal.rs | 1 |
5 files changed, 23 insertions, 22 deletions
diff --git a/src/components/mail/listing.rs b/src/components/mail/listing.rs index d6798e0c..ae4f85f0 100644 --- a/src/components/mail/listing.rs +++ b/src/components/mail/listing.rs @@ -84,9 +84,9 @@ impl Default for Modifier { #[derive(Debug, Default, Clone)] pub struct DataColumns { - pub columns: [CellBuffer; 12], + pub columns: Box<[CellBuffer; 12]>, pub widths: [usize; 12], // widths of columns calculated in first draw and after size changes - pub segment_tree: [SegmentTree; 12], + pub segment_tree: Box<[SegmentTree; 12]>, } #[derive(Debug, Default)] diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index bf051ced..2ae5ce0d 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -188,7 +188,7 @@ pub struct CompactListing { force_draw: bool, /// If `self.view` exists or not. focus: Focus, - view: ThreadView, + view: Box<ThreadView>, row_updates: SmallVec<[ThreadHash; 8]>, color_cache: ColorCache, @@ -307,7 +307,7 @@ impl MailListingTrait for CompactListing { } else if self.unfocused() { let thread = self.get_thread_under_cursor(self.cursor_pos.2); - self.view = ThreadView::new(self.new_cursor_pos, thread, None, context); + self.view = Box::new(ThreadView::new(self.new_cursor_pos, thread, None, context)); } } @@ -491,7 +491,7 @@ impl ListingTrait for CompactListing { fn set_coordinates(&mut self, coordinates: (AccountHash, MailboxHash)) { self.new_cursor_pos = (coordinates.0, coordinates.1, 0); self.focus = Focus::None; - self.view = ThreadView::default(); + self.view = Box::new(ThreadView::default()); self.filtered_selection.clear(); self.filtered_order.clear(); self.filter_term.clear(); @@ -897,7 +897,7 @@ impl CompactListing { rows: vec![], dirty: true, force_draw: true, - view: ThreadView::default(), + view: Box::new(ThreadView::default()), color_cache: ColorCache::default(), movement: None, modifier_active: false, @@ -1785,7 +1785,7 @@ impl Component for CompactListing { || shortcut!(k == shortcuts[Listing::DESCRIPTION]["focus_right"])) => { let thread = self.get_thread_under_cursor(self.cursor_pos.2); - self.view = ThreadView::new(self.cursor_pos, thread, None, context); + self.view = Box::new(ThreadView::new(self.cursor_pos, thread, None, context)); self.set_focus(Focus::Entry, context); return true; } diff --git a/src/components/mail/listing/thread.rs b/src/components/mail/listing/thread.rs index dd9b1114..464fc352 100644 --- a/src/components/mail/listing/thread.rs +++ b/src/components/mail/listing/thread.rs @@ -131,7 +131,7 @@ pub struct ThreadListing { /// If `self.view` is focused or not. focus: Focus, initialised: bool, - view: Option<MailView>, + view: Option<Box<MailView>>, movement: Option<PageMovement>, id: ComponentId, } @@ -773,7 +773,7 @@ impl ListingTrait for ThreadListing { if let Some(ref mut v) = self.view { v.update(coordinates, context); } else { - self.view = Some(MailView::new(coordinates, None, None, context)); + self.view = Some(Box::new(MailView::new(coordinates, None, None, context))); } if let Some(ref mut s) = self.view { @@ -1239,7 +1239,7 @@ impl Component for ThreadListing { if let Some(ref mut v) = self.view { v.update(coordinates, context); } else { - self.view = Some(MailView::new(coordinates, None, None, context)); + self.view = Some(Box::new(MailView::new(coordinates, None, None, context))); } if let Some(v) = self.view.as_mut() { diff --git a/src/state.rs b/src/state.rs index a67e2fac..73f8c220 100644 --- a/src/state.rs +++ b/src/state.rs @@ -97,7 +97,7 @@ impl InputHandler { /// A context container for loaded settings, accounts, UI changes, etc. pub struct Context { pub accounts: IndexMap<AccountHash, Account>, - pub settings: Settings, + pub settings: Box<Settings>, /// Areas of the screen that must be redrawn in the next render pub dirty_areas: VecDeque<Area>, @@ -168,13 +168,13 @@ impl Context { /// A State object to manage and own components and components of the UI. `State` is responsible for /// managing the terminal and interfacing with `melib` pub struct State { - screen: Screen, + screen: Box<Screen>, draw_rate_limit: RateLimit, child: Option<ForkType>, pub mode: UIMode, overlay: Vec<Box<dyn Component>>, components: Vec<Box<dyn Component>>, - pub context: Context, + pub context: Box<Context>, timer: thread::JoinHandle<()>, display_messages: SmallVec<[DisplayMessage; 8]>, @@ -228,11 +228,11 @@ impl State { let input_thread_pipe = nix::unistd::pipe() .map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>)?; let backends = Backends::new(); - let settings = if let Some(settings) = settings { + let settings = Box::new(if let Some(settings) = settings { settings } else { Settings::new()? - }; + }); /* let mut plugin_manager = PluginManager::new(); for (_, p) in settings.plugins.clone() { @@ -307,7 +307,7 @@ impl State { let working = Arc::new(()); let control = Arc::downgrade(&working); let mut s = State { - screen: Screen { + screen: Box::new(Screen { cols, rows, grid: CellBuffer::new(cols, rows, Cell::with_char(' ')), @@ -319,7 +319,7 @@ impl State { } else { Screen::draw_horizontal_segment_no_color }, - }, + }), child: None, mode: UIMode::Normal, components: Vec::with_capacity(8), @@ -333,7 +333,7 @@ impl State { display_messages_dirty: false, display_messages_initialised: false, display_messages_area: ((0, 0), (0, 0)), - context: Context { + context: Box::new(Context { accounts, settings, dirty_areas: VecDeque::with_capacity(5), @@ -351,7 +351,7 @@ impl State { }, sender, receiver, - }, + }), }; if s.context.settings.terminal.ascii_drawing { s.screen.grid.set_ascii_drawing(true); @@ -395,7 +395,7 @@ impl State { } let Context { ref mut accounts, .. - } = &mut self.context; + } = &mut *self.context; if let Some(notification) = accounts[&account_hash].reload(event, mailbox_hash) { if let UIEvent::Notification(_, _, _) = notification { @@ -948,10 +948,10 @@ impl State { if toml::Value::try_from(&new_settings) == toml::Value::try_from(&self.context.settings) { return Err("No changes detected.".into()); } - Ok(new_settings) + Ok(Box::new(new_settings)) }) { Ok(new_settings) => { - let old_settings = Box::new(std::mem::replace(&mut self.context.settings, new_settings)); + let old_settings = std::mem::replace(&mut self.context.settings, new_settings); self.context.replies.push_back(UIEvent::ConfigReload { old_settings }); diff --git a/src/terminal.rs b/src/terminal.rs index 57e3774e..916c77f2 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -463,6 +463,7 @@ pub mod screen { use termion::{clear, cursor}; pub type StateStdout = termion::screen::AlternateScreen<termion::raw::RawTerminal<BufWriter<std::io::Stdout>>>; + pub struct Screen { pub cols: usize, pub rows: usize, |