Skip to content

add BigDecimal and BigInt cache in RefineMacro#1245

Merged
fthomas merged 1 commit intofthomas:masterfrom
xuwei-k:patch-2
Jan 26, 2024
Merged

add BigDecimal and BigInt cache in RefineMacro#1245
fthomas merged 1 commit intofthomas:masterfrom
xuwei-k:patch-2

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
@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