Skip to content
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

add BigDecimal and BigInt cache in RefineMacro #1245

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

xuwei-k
Copy link
Contributor

@xuwei-k xuwei-k commented Jan 25, 2024

for avoid eval

@xuwei-k
Copy link
Contributor Author

xuwei-k commented Jan 26, 2024

Before

Welcome to Scala 2.13.12 (OpenJDK 64-Bit Server VM, Java 11.0.21).
Type in expressions for evaluation. Or try :help.
import eu.timepit.refined._
import eu.timepit.refined.api._
import eu.timepit.refined.api.Inference.$eq$eq$greater
import eu.timepit.refined.api.RefType.ops._
import eu.timepit.refined.auto._
import eu.timepit.refined.predicates.all._
import eu.timepit.refined.types.all._
import shapeless.{$colon$colon, HList, HNil}
import shapeless.nat._
import shapeless.tag.$at$at

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res0: Long = 633

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res1: Long = 337

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res2: Long = 280

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res3: Long = 266

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res4: Long = 260

After

Welcome to Scala 2.13.12 (OpenJDK 64-Bit Server VM, Java 11.0.21).
Type in expressions for evaluation. Or try :help.
import eu.timepit.refined._
import eu.timepit.refined.api._
import eu.timepit.refined.api.Inference.$eq$eq$greater
import eu.timepit.refined.api.RefType.ops._
import eu.timepit.refined.auto._
import eu.timepit.refined.predicates.all._
import eu.timepit.refined.types.all._
import shapeless.{$colon$colon, HList, HNil}
import shapeless.nat._
import shapeless.tag.$at$at

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res0: Long = 85

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res1: Long = 77

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res2: Long = 71

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res3: Long = 71

scala> shapeless.test.compileTime(""" val x: PosBigDecimal = BigDecimal(2) """).toMillis
val res4: Long = 69

Copy link
Owner

@fthomas fthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @xuwei-k!

@fthomas fthomas merged commit 6f6f5d5 into fthomas:master Jan 26, 2024
5 checks passed
@xuwei-k xuwei-k deleted the patch-2 branch January 26, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants