Improve Compilation Performance/ Code Quality #103
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog
cargo-machete
)cargo-unused-features
)cargo-update
)cargo-fmt
cargo tree -d --edges normal
)enquote
a mac-only dependency (#cfg(macos)
->#cfg(target_os = "macos")
)) Enquote Failure for Mac Installation #43default_features
todefault-features
Some ideas on further code cleanup/ compile time reducation
See comments in
Cargo.toml
ahash
I don't see any reason why we would need a custom hashing algorithm?
If there is a reason that should probably be documented.
In case it's just an optimization (which I'll assume because there's no other reason documented), there should at least be a benchmark or sth to prove it's necessary
indexmap
Not too sure about this one. If the data isn't too large we could probably get away with sorting a Vec?
Or even better, use a
BTreeSet
instead.The IndexMap is only used once.
src/scheme.rs
CHANGELOG.md
saysWhich I don't really understand because the tables color order is deterministic anyways?
resolve-path
This one is only used once in this function
src/util/template.rs
Again this functions documentation could be improved.
Why would you ever want to resolve paths relative to the file the config is in?
Relative paths starting with . should clearly be prohibited.
There's no reasonable expected output you could have for them.
In Rust 1.79 they added std::path::absolute which we could maybe use instead.
Honestly tho I don't really understand why we even need to have an absolute path.
Code Quality Rant:
Template
.src/util/template.rs
is badly named. Template.rs is not a utility at all. It's literally a main part of the functionality. Consider moving it intosrc/template.rs
?Sorry for going a little off-topic here but the code quality (especially of the part handling files) is a bit questionable.
execute
I didn't put too much research into that (partially because the hooks aren't documented),
but it feels like this could be done with std easily.
This is the only usecase (apart from traits)
src/exec/hook.rs
paris
The paris crate is way more popular than paris-log and we don't seem to require the log crate in any way
so why are we installing 3 dependencies instead of just using one?
Migrating this is a bit more effort but the Logger struct also looks more ergonomic to use than the macros we're currently using.
enquote
andwinapi
I'd suggest just using the
wallpaper
crate instead. It seems to be less hacky than the current macOS implementation.For linux we could just keep the current code.
the wallpaper module currently has 179 LOCS, 120 of which are for the unix stuff. that means we could remove ~59 + we don't have to maintain windows and mac specific stuff. Sounds like a pretty good idea to me.
Benchmarks
Here's the compilation performance improvement
Default Features
All Features