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
Experimenting with by-name implicit parameters for generic derivation #1180
Conversation
Note that we'll need scalameta/scalameta#1880 for Scalafmt to work here (it seems like you can set |
Codecov Report
@@ Coverage Diff @@
## master #1180 +/- ##
==========================================
+ Coverage 85.58% 85.89% +0.31%
==========================================
Files 89 89
Lines 2885 2885
Branches 115 119 +4
==========================================
+ Hits 2469 2478 +9
+ Misses 416 407 -9
Continue to review full report at Codecov.
|
997c881
to
dcbd415
Compare
gen: LabelledGeneric.Aux[A, R], | ||
codec: => ReprAsObjectCodec[R] | ||
): DerivedAsObjectCodec[A] = new DerivedAsObjectCodec[A] { | ||
final def apply(c: HCursor): Decoder.Result[A] = codec.apply(c) match { |
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.
Do you not need to cache codec in a lazy val to avoid executing it again and again for each call to apply?
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.
Yeah, I meant to go back and do a pass for runtime performance stuff like this after getting it correct. I've just opened #1183. Thanks for catching.
This PR introduces a 2.13-only rewrite of circe-generic (as a new circe-generic-simple module, for now at least) that passes the same tests as circe-generic but completely removes
DerivationMacros
; the only macros are for the export mechanism and the@JsonCodec
macro annotation. All of theshapeless.Lazy
occurrences are gone—most have been replaced by by-name implicit parameters, but a few don't seem to be needed at all with 2.13.In addition to having a less terrifying implementation, circe-generic-simple also provides much faster compilation (up to ~30% for some of my examples).