diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-07-18 12:20:17 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-07-18 12:20:17 -0400 |
commit | a44601a414615b488b9814ea28f3cd6bd1086989 (patch) | |
tree | a65c94796fed2ddb7cc664f2288353c8913c1fb7 | |
parent | 28eef944917235f8add893cf4044b1ae7baac221 (diff) |
increase performance by boxing values before sending
-rw-r--r-- | src/event/app_event.rs | 4 | ||||
-rw-r--r-- | src/event/process_event.rs | 6 | ||||
-rw-r--r-- | src/preview/preview_dir.rs | 2 | ||||
-rw-r--r-- | src/preview/preview_file.rs | 4 |
4 files changed, 7 insertions, 9 deletions
diff --git a/src/event/app_event.rs b/src/event/app_event.rs index a22b0f7..05f5d02 100644 --- a/src/event/app_event.rs +++ b/src/event/app_event.rs @@ -28,8 +28,8 @@ pub enum AppEvent { ChildProcessComplete(u32), // preview thread events - PreviewDir(io::Result<JoshutoDirList>), - PreviewFile(path::PathBuf, io::Result<FilePreview>), + PreviewDir(io::Result<Box<JoshutoDirList>>), + PreviewFile(path::PathBuf, Box<io::Result<FilePreview>>), // terminal size change events Signal(i32), diff --git a/src/event/process_event.rs b/src/event/process_event.rs index f8fe41a..8eb6136 100644 --- a/src/event/process_event.rs +++ b/src/event/process_event.rs @@ -58,10 +58,8 @@ pub fn process_noninteractive(event: AppEvent, context: &mut AppContext) { AppEvent::IoWorkerCreate => process_new_worker(context), AppEvent::FileOperationProgress(res) => process_worker_progress(context, res), AppEvent::IoWorkerResult(res) => process_finished_worker(context, res), - AppEvent::PreviewDir(Ok(dirlist)) => process_dir_preview(context, dirlist), - AppEvent::PreviewFile(path, file_preview) => { - process_file_preview(context, path, file_preview) - } + AppEvent::PreviewDir(Ok(b)) => process_dir_preview(context, *b), + AppEvent::PreviewFile(path, b) => process_file_preview(context, path, *b), AppEvent::Signal(signal::SIGWINCH) => {} AppEvent::Filesystem(e) => process_filesystem_event(e, context), AppEvent::ChildProcessComplete(child_id) => { diff --git a/src/preview/preview_dir.rs b/src/preview/preview_dir.rs index c5c4ee8..b74e606 100644 --- a/src/preview/preview_dir.rs +++ b/src/preview/preview_dir.rs @@ -14,7 +14,7 @@ impl Background { thread::spawn(move || { if let Ok(dirlist) = JoshutoDirList::from_path(p, &options) { - let _ = event_tx.send(AppEvent::PreviewDir(Ok(dirlist))); + let _ = event_tx.send(AppEvent::PreviewDir(Ok(Box::new(dirlist)))); } }) } diff --git a/src/preview/preview_file.rs b/src/preview/preview_file.rs index f929b2e..d89ee4b 100644 --- a/src/preview/preview_file.rs +++ b/src/preview/preview_file.rs @@ -70,10 +70,10 @@ impl Background { match res { Ok(output) => { let preview = FilePreview::from(output); - let _ = event_tx.send(AppEvent::PreviewFile(path, Ok(preview))); + let _ = event_tx.send(AppEvent::PreviewFile(path, Box::new(Ok(preview)))); } Err(e) => { - let _ = event_tx.send(AppEvent::PreviewFile(path, Err(e))); + let _ = event_tx.send(AppEvent::PreviewFile(path, Box::new(Err(e)))); } } }); |