-
Notifications
You must be signed in to change notification settings - Fork 323
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
Low-hanging perf improvements #10462
Conversation
- avoid loading shapeless for the sole purpose of having a compile-time type inequality - don't use `sys.env` to avoid some Scala conversions - lazy initialization of fields
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.
Removing a library dependency is always a good sign.
|
||
// https://stackoverflow.com/questions/6909053/enforce-type-difference | ||
|
||
sealed class =!=[A, B] |
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.
Not that copying this code into our repository would simplify the magic...
@@ -2226,7 +2226,6 @@ lazy val `runtime-compiler` = | |||
annotationProcSetting, | |||
(Test / fork) := true, | |||
libraryDependencies ++= Seq( | |||
"com.chuusai" %% "shapeless" % shapelessVersion % "provided", |
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.
I don't see any other usages of shapelessVersion
. I guess:
val shapelessVersion = "2.3.10"
should also be removed then.
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.
Yes, thanks
@@ -146,7 +145,7 @@ object IRPass { | |||
*/ | |||
@throws[CompilerError] | |||
def unsafeAs[T <: Metadata: ClassTag](implicit | |||
@unused ev: T =:!= Metadata | |||
@unused ev: T =!= Metadata |
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.
Is this a Scala way of doing Kotlin's reified classes?
Wouldn't it be simpler to just delete the method implicit magic altogether and just pass in the argument explicitly?
Btw. Why is the method called unsafeAs
then? Reified classes can be checked during runtime in Kotlin and I see some runtime check here as well.
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.
The sole purpose of this logic is to ensure at compile time that neither type inferencer nor explicit type argument result in T being Metadata
rather than its subclass.
I don't think providing explicit argument to every usage site is better, plus it doesn't prevent incorrect usage this implicit prevents from.
Pull Request Description
type inequality
sys.env
to avoid some Scala conversionsImportant Notes
On a slow machine, so easier to spot.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.