Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Instantly share code, notes, and snippets.

TaskKey[Seq[String]]("allMainClassNames") := Def.taskDyn {
buildStructure.value.units
.apply(Keys.thisProjectRef.value.build)
.defined
.values
.toList
.map { p =>
LocalProject(p.id) / Compile / discoveredMainClasses
}
.join
@xuwei-k
xuwei-k / Main.scala
Last active February 5, 2025 02:39
profile scodec
package example
import scodec.bits.*
import scodec.codecs.*
object Main {
val iterations = 1000000000
val str = "Hello World!"
  • 6.543094 Null
  • 5.654039 MapUnit
  • 4.128198 SeqApply
  • 1.990676 StringPlusAny
  • 1.58011 AutoUnboxing
  • 1.447845 IterableOps
  • 1.424732 PlatformDefault
  • 1.257947 Equals
  • 1.251545 Overloading
  • 0.813279 RedundantIsInstanceOf
  • ImplicitParameter 1.065469
  • Overloading 0.510683
  • Null 0.334346
  • AutoUnboxing 0.280608
  • ListAppend 0.24645
  • IterableOps 0.130154
  • SortFilter 0.107256
  • Recursion 0.102776
  • Any 0.100167
  • AsInstanceOf 0.060164
@xuwei-k
xuwei-k / img1.png
Last active January 22, 2025 01:10
img1.png
package fix
import scala.meta.Defn
import scala.meta.Term
import scala.meta.transversers.*
import scalafix.Patch
import scalafix.lint.Diagnostic
import scalafix.lint.LintSeverity
import scalafix.v1.SyntacticDocument
import scalafix.v1.SyntacticRule
object ScalaRunTimeForScalaJS {
def main(a: Array[String]): Unit = {
println(replStringOf((1 to 200).toList, 10))
}
def replStringOf(arg: Any, maxElements: Int): String =
stringOf(arg, maxElements) match {
case null => "null toString"
case s if s.indexOf('\n') >= 0 => "\n" + s + "\n"
case s => s + "\n"
import org.wartremover.WartTraverser
import org.wartremover.WartUniverse
object StringTailInit extends WartTraverser {
def apply(u: WartUniverse): u.Traverser =
new u.Traverser(this) {
import q.reflect.*
override def traverseTree(tree: Tree)(owner: Symbol): Unit = {
tree match {
case Select(Apply(Ident("augmentString"), _ :: Nil), "init" | "tail") =>
@xuwei-k
xuwei-k / Main.scala
Last active December 2, 2024 23:43
Scala 3 generic numeric literals example
package example
import scala.compiletime.testing.typeCheckErrors
object Main {
val x1: PosInt = 2
def main(args: Array[String]): Unit = {
println(x1)