Skip to content

Commit

Permalink
Merge pull request #706 from scala-steward/update/scalafmt-core-3.3.3
Browse files Browse the repository at this point in the history
scalafmt-core 3.3.3 (was 3.3.1)
  • Loading branch information
mkurz authored Jan 29, 2022
2 parents 9c2521a + a3b32a4 commit 0e09d8a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.3.1
version = 3.3.3
runner.dialect = Scala213Source3

align.preset = true
Expand Down
22 changes: 11 additions & 11 deletions benchmarks/src/main/scala/play/api/libs/json/Employee.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
package play.api.libs.json

case class Employee(
employeeNumber: Int,
firstName: String,
lastName: String,
city: String,
country: String,
tags: Seq[String]
employeeNumber: Int,
firstName: String,
lastName: String,
city: String,
country: String,
tags: Seq[String]
)

object Employee {
Expand All @@ -19,11 +19,11 @@ object Employee {
val manualWrites: Writes[Employee] = Writes { e =>
Json.obj(
"employeeNumber" -> e.employeeNumber,
"firstName" -> e.firstName,
"lastName" -> e.lastName,
"city" -> e.city,
"country" -> e.country,
"tags" -> JsArray(e.tags.map(JsString.apply))
"firstName" -> e.firstName,
"lastName" -> e.lastName,
"city" -> e.city,
"country" -> e.country,
"tags" -> JsArray(e.tags.map(JsString.apply))
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import org.openjdk.jmh.annotations._
class JsonDeserialize_01_List {

var employees: Seq[Employee] = _
var employeesJson: JsValue = _
var employeesJson: JsValue = _

@Setup(Level.Iteration)
def setup(): Unit = {
val employees: Seq[Employee] = (1 to 100) map { id =>
val employees: Seq[Employee] = (1.to(100)).map { id =>
Employee(
id,
s"Foo$id",
Expand All @@ -28,9 +28,7 @@ class JsonDeserialize_01_List {
}

@TearDown(Level.Iteration)
def tearDown(): Unit = {

}
def tearDown(): Unit = {}

@Benchmark
def jsonAs(): JsValue = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class JsonDeserialize_02_Nullable {

case class NullableFields(field1: Option[String], field2: Option[String], field3: Option[String])

private val json = Json.obj("field1" -> "value1", "field2" -> "value2")
private var result: NullableFields = _
private val json = Json.obj("field1" -> "value1", "field2" -> "value2")
private var result: NullableFields = _
private implicit val nullableFields: Reads[NullableFields] = Json.reads

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.openjdk.jmh.annotations._
@State(Scope.Benchmark)
class JsonMacros_01_SerializeSimpleCaseClass {

var employee: Employee = _
var employee: Employee = _
var employeeJson: JsValue = _

@Setup(Level.Iteration)
Expand All @@ -26,15 +26,14 @@ class JsonMacros_01_SerializeSimpleCaseClass {

@TearDown(Level.Iteration)
def tearDown(): Unit = {
assert(employeeJson == Json.parse(
""" {
| "employeeNumber": 42,
| "firstName": "Foo",
| "lastName": "Bar",
| "city": "New York",
| "country": "United States",
| "tags": ["engineering", "new", "bar"]
| }
assert(employeeJson == Json.parse(""" {
| "employeeNumber": 42,
| "firstName": "Foo",
| "lastName": "Bar",
| "city": "New York",
| "country": "United States",
| "tags": ["engineering", "new", "bar"]
| }
""".stripMargin))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import org.openjdk.jmh.annotations._
class JsonMacros_02_SerializeList {

var employees: Seq[Employee] = _
var employeesJson: JsValue = _
var employeesJson: JsValue = _

@Setup(Level.Iteration)
def setup(): Unit = {
employees = (1 to 100) map { id =>
employees = (1.to(100)).map { id =>
Employee(
id,
s"Foo$id",
Expand All @@ -27,9 +27,7 @@ class JsonMacros_02_SerializeList {
}

@TearDown(Level.Iteration)
def tearDown(): Unit = {

}
def tearDown(): Unit = {}

@Benchmark
def toJson(): JsValue = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package play.api.libs.json
import org.openjdk.jmh.annotations._

/**
* @see https://github.com/playframework/play-json/pull/193
*/
* @see https://github.com/playframework/play-json/pull/193
*/
@State(Scope.Benchmark)
class JsonParsing_01_ParseManyFields {
@Param(Array("10", "100", "1000", "10000", "100000"))
Expand All @@ -24,7 +24,8 @@ class JsonParsing_01_ParseManyFields {
@Setup
def setup(): Unit = {
val value = "42"
stringToParse = HashCodeCollider.zeroHashCodeStrings.take(n)
stringToParse = HashCodeCollider.zeroHashCodeStrings
.take(n)
.mkString("""{"s":"s","""", s"""":$value,"""", s"""":$value,"i":1}""")
}

Expand Down

0 comments on commit 0e09d8a

Please sign in to comment.