Remove AsRef generics to reduce compilation time & binary size#336
Open
malcolmgreaves wants to merge 2 commits intomainfrom
Open
Remove AsRef generics to reduce compilation time & binary size#336malcolmgreaves wants to merge 2 commits intomainfrom
malcolmgreaves wants to merge 2 commits intomainfrom
Conversation
Contributor
|
Important Review skippedToo many files! This PR contains 251 files, which is 101 over the limit of 150. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (251)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c816ff3 to
3d69698
Compare
a573668 to
b30f14e
Compare
Replaces all generic `AsRef<X>` uses with `&X` direct references. Includes all instances of a generic parameter of the form `Y: AsRef<X>` and `impl AsRef<X>`. Notably, this included many `AsRef<str>` and `AsRef<Path>`, which are now replaced with `&str` and `&Path`, respectively. This cuts down on compilation time and binary size considerably. Since Rust monomorphizes generics: it must compile new variants of each function for every different concrete type use. Unlike other traits, the codebase's use of `AsRef` doesn't provide much utility as we nearly never swap-out different things that could be turned into the reference type. The code is not only smaller and faster to compile, it is clearer in what, exactly, it requires and what it exactly operates on.
b30f14e to
f75ef0f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replaces all generic
AsRef<X>uses with&Xdirect references.Includes all instances of a generic parameter of the form
Y: AsRef<X>andimpl AsRef<X>. Notably, this included manyAsRef<str>andAsRef<Path>,which are now replaced with
&strand&Path, respectively.This cuts down on compilation time and binary size considerably. Since
Rust monomorphizes generics: it must compile new variants of each function
for every different concrete type use. Unlike other traits, the codebase's
use of
AsRefdoesn't provide much utility as we nearly never swap-outdifferent things that could be turned into the reference type. The code is
not only smaller and faster to compile, it is clearer in what, exactly,
it requires and what it exactly operates on.