Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use BTreeMap for deterministic drop order
Because of the use of the static ROUTE_ID counter, the internal ordering of the HashMap depends on when the routes are added to the Router. Routes can cause arbitrary code to run when they are dropped, so this is an unwanted source of non determinism. (Even controlling the HashMap's RandomState will not help in this case). A BTreeMap guarantees routes are dropped in the order they were created, and. I also suspect it will be no slower (and maybe faster) for small numbers of routes (the common case). This is not performance critical code in any case.
- Loading branch information