more clippy::complexity fixes (also a couple of clippy::perf fixes)
For more information about how rustc works, see the rustc dev guide.