diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-05-31 10:02:13 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-05-31 10:02:13 +0800 |
commit | 91aade36c71e4e14167030b6ec8c3c13dcdc1b2b (patch) | |
tree | 0fd1df11e7cb3b7be9370add84de043b4fd1d5f5 | |
parent | 31778d7517cf27f5a5effccc7373b71833546098 (diff) |
Avoid deallocation a potentially big hashmap
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 7f505d9..2a3936a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,13 +50,18 @@ fn run() -> Result<(), Error> { paths_from(input)?, Interaction::Full, )? - .map(|(keys_rx, mut app)| app.process_events(&mut terminal, keys_rx.into_iter())); + .map(|(keys_rx, mut app)| { + let res = app.process_events(&mut terminal, keys_rx.into_iter()); + // Leak app memory to avoid having to wait for the hashmap to deallocate, which causes a noticable delay shortly before the the + // program exits anyway. + std::mem::forget(app); + res + }); drop(terminal); io::stdout().flush().ok(); - // Exit 'quickly' to avoid having to wait for all memory to be freed by us. - // Let the OS do it - we have nothing to lose, literally. + // Exit 'quickly' to avoid having to not have to deal with slightly different types in the other match branches std::process::exit(res.transpose()?.map(|e| e.to_exit_code()).unwrap_or(0)); } Some(Aggregate { |