AMythicDev / minus

An asynchronous, runtime data feedable terminal paging library for Rust
https://crates.io/crates/minus/
Apache License 2.0
321 stars 23 forks source link

Remove unnecessary refcell usage in start_reactor #63

Closed itsjunetime closed 2 years ago

itsjunetime commented 2 years ago

In start_reactor (in src/core/init.rs), RefCells are used unnecessarily so that the match arm closures can be declared as variables. However, if we don't declare these arms as variables and instead just insert them at the end of the match arms, we don't have to use refcells to store these variables. This also allows us to lock stdout (which is also implemented in this PR), which should make paging quicker and decrease flicker when scrolling quickly.

AMythicDev commented 2 years ago

I was kinda surprised at this syntax.

MATCHARM => loop {
// ...
}

Didn't knew this even existed