riker-rs / riker

Easily build efficient, highly concurrent and resilient applications. An Actor Framework for Rust.
https://riker.rs
MIT License
1.02k stars 69 forks source link

Simplify provider::register() #127

Closed hardliner66 closed 4 years ago

hardliner66 commented 4 years ago

Currently the register method checks if a path is already in the dashmap. If it is, it calls replace which returns the old value if one was present. If the old value was present, it replaces the old value again.

Because the value is always () and replace already handles the case where a path is already registered, this method can be simplified which should make reasoning about the code easier. This should also make it a bit faster, because it removes duplicate calls to replace and one one unnecessary call to contains_key.