-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generator: Replace Extends{Root}
with StructExtends<Root>
generic
#971
base: master
Are you sure you want to change the base?
Conversation
5e377f7
to
8e98f8d
Compare
8e98f8d
to
1cf5047
Compare
It looks like this PR comes with a ±150ms build speedup:
|
Awesome! Glad we finally stumbled on something that helps there, and great that it's a readability/concision win too. |
Sneak-preview: moving the functions to |
b2b971f
to
28ffd5e
Compare
Instead of emitting a new `trait` for every `Root` struct that is being implemented by one or more "child" structs (those that have `Root` in their `structextends`), create one trait that takes the root struct as a generic parameter, and implement that directly instead. This not only saves on having to define the `trait` for every `Root` struct but also paves the way towards providing default trait implementations for any pair of root and child struct, such as the `p_next` builder methods.
28ffd5e
to
4305ec7
Compare
Performance optimization is now less significant, ±105ms, perhaps because of the expanded lifetimes? (Retested This PR (4305ec7):❯ hyperfine -p 'cargo clean -p ash' 'cargo b -p ash'
Benchmark 1: cargo b -p ash
Time (mean ± σ): 7.858 s ± 0.103 s [User: 7.702 s, System: 0.876 s]
Range (min … max): 7.745 s … 8.026 s 10 runs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're done here, right? I'm happy to discuss changing the lifetime semantics to try to recapture some of that buildtime if you want, but it's a net win regardless.
Works towards #879, yet without swapping the generic and the struct to implement it for.
Instead of emitting a new
trait
for everyRoot
struct that is being implemented by one or more "child" structs (those that haveRoot
in theirstructextends
), create one trait that takes the root struct as a generic parameter, and implement that directly instead.This not only saves on having to define the
trait
for everyRoot
struct but also paves the way towards providing default trait implementations for any pair of root and child struct, such as thep_next
builder methods.