Skip to content

Commit 13199c3

Browse files
committed
reduce JsSuccess and JsError instance size
before ``` play.api.libs.json.JsError object internals: OFF SZ TYPE DESCRIPTION VALUE 0 8 (object header: mark) N/A 8 4 (object header: class) N/A 12 1 boolean JsError.isSuccess N/A 13 1 boolean JsError.isError N/A 14 2 (alignment/padding gap) 16 4 scala.collection.Seq JsError.errors N/A 20 4 scala.None$ JsError.asOpt N/A Instance size: 24 bytes Space losses: 2 bytes internal + 0 bytes external = 2 bytes total ``` after ``` play.api.libs.json.JsError object internals: OFF SZ TYPE DESCRIPTION VALUE 0 8 (object header: mark) N/A 8 4 (object header: class) N/A 12 4 scala.collection.Seq JsError.errors N/A Instance size: 16 bytes Space losses: 0 bytes internal + 0 bytes external = 0 bytes total ```
1 parent 02e70c4 commit 13199c3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

play-json/shared/src/main/scala/play/api/libs/json/JsResult.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import scala.collection.Seq
1212
case class JsSuccess[T](value: T, path: JsPath = JsPath()) extends JsResult[T] {
1313
def get: T = value
1414

15-
val isSuccess = true
16-
val isError = false
15+
def isSuccess = true
16+
def isError = false
1717

1818
def fold[U](invalid: Seq[(JsPath, Seq[JsonValidationError])] => U, valid: T => U): U = valid(value)
1919

@@ -60,8 +60,8 @@ case class JsError(errors: Seq[(JsPath, Seq[JsonValidationError])]) extends JsRe
6060
def +:(error: (JsPath, JsonValidationError)): JsError = JsError.merge(JsError(error), this)
6161
def prepend(error: (JsPath, JsonValidationError)): JsError = this.+:(error)
6262

63-
val isSuccess = false
64-
val isError = true
63+
def isSuccess = false
64+
def isError = true
6565

6666
def fold[U](invalid: Seq[(JsPath, Seq[JsonValidationError])] => U, valid: Nothing => U): U = invalid(errors)
6767

@@ -84,7 +84,7 @@ case class JsError(errors: Seq[(JsPath, Seq[JsonValidationError])]) extends JsRe
8484

8585
def orElse[U >: Nothing](t: => JsResult[U]): JsResult[U] = t
8686

87-
val asOpt = None
87+
def asOpt = None
8888

8989
def asEither: Either[Seq[(JsPath, Seq[JsonValidationError])], Nothing] = Left(errors)
9090

0 commit comments

Comments
 (0)