Switch to mimalloc

This commit is contained in:
itsjunetime
2024-11-27 18:57:39 -07:00
parent cc46791627
commit 65e1f1a205
7 changed files with 64 additions and 44 deletions
+3
View File
@@ -1,3 +1,6 @@
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
pub mod converter;
pub mod renderer;
pub mod skip;
+8 -11
View File
@@ -4,7 +4,6 @@ use std::{
path::PathBuf
};
use converter::{run_conversion_loop, ConvertedPage, ConverterMsg};
use crossterm::{
execute,
terminal::{
@@ -17,13 +16,11 @@ use glib::{LogField, LogLevel, LogWriterOutput};
use notify::{Event, EventKind, RecursiveMode, Watcher};
use ratatui::{backend::CrosstermBackend, Terminal};
use ratatui_image::picker::Picker;
use renderer::{RenderError, RenderInfo, RenderNotif};
use tui::{InputAction, Tui};
mod converter;
mod renderer;
mod skip;
mod tui;
use tdf::{
converter::{run_conversion_loop, ConvertedPage, ConverterMsg},
renderer::{self, RenderError, RenderInfo, RenderNotif},
tui::{InputAction, Tui}
};
// Dummy struct for easy errors in main
#[derive(Debug)]
@@ -143,7 +140,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|| "Unknown file".into(),
|n| n.to_string_lossy().to_string()
);
let mut tui = tui::Tui::new(file_name, flags.max_wide, flags.r_to_l.unwrap_or_default());
let mut tui = Tui::new(file_name, flags.max_wide, flags.r_to_l.unwrap_or_default());
let backend = CrosstermBackend::new(std::io::stdout());
let mut term = Terminal::new(backend)?;
@@ -161,7 +158,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)?;
enable_raw_mode()?;
let mut main_area = tui::Tui::main_layout(&term.get_frame());
let mut main_area = Tui::main_layout(&term.get_frame());
tui_tx.send(RenderNotif::Area(main_area[1]))?;
let mut tui_rx = tui_rx.into_stream();
@@ -259,7 +256,7 @@ fn on_notify_ev(
// happened, then like the main thread has panicked or something, so it doesn't matter
// we don't handle the error here.
EventKind::Other | EventKind::Any | EventKind::Create(_) | EventKind::Modify(_) =>
drop(to_render_tx.send(renderer::RenderNotif::Reload)),
drop(to_render_tx.send(RenderNotif::Reload)),
}
}
}
+3 -5
View File
@@ -76,13 +76,11 @@ pub fn start_rendering(
) -> Result<(), SendError<Result<RenderInfo, RenderError>>> {
// first, wait 'til we get told what the current starting area is so that we can set it to
// know what to render to
let mut area;
loop {
let mut area = loop {
if let RenderNotif::Area(r) = receiver.recv().unwrap() {
area = r;
break;
break r;
}
}
};
// We want this outside of 'reload so that if the doc reloads, the search term that somebody
// set will still get highlighted in the reloaded doc