Skip to content

Commit 91aade3

Browse files
committed
Avoid deallocation a potentially big hashmap
1 parent 31778d7 commit 91aade3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ fn run() -> Result<(), Error> {
5050
paths_from(input)?,
5151
Interaction::Full,
5252
)?
53-
.map(|(keys_rx, mut app)| app.process_events(&mut terminal, keys_rx.into_iter()));
53+
.map(|(keys_rx, mut app)| {
54+
let res = app.process_events(&mut terminal, keys_rx.into_iter());
55+
// Leak app memory to avoid having to wait for the hashmap to deallocate, which causes a noticable delay shortly before the the
56+
// program exits anyway.
57+
std::mem::forget(app);
58+
res
59+
});
5460

5561
drop(terminal);
5662
io::stdout().flush().ok();
5763

58-
// Exit 'quickly' to avoid having to wait for all memory to be freed by us.
59-
// Let the OS do it - we have nothing to lose, literally.
64+
// Exit 'quickly' to avoid having to not have to deal with slightly different types in the other match branches
6065
std::process::exit(res.transpose()?.map(|e| e.to_exit_code()).unwrap_or(0));
6166
}
6267
Some(Aggregate {

0 commit comments

Comments
 (0)