Skip to content

Commit

Permalink
avoid allocation in Validator.All.contramap (#3555)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil authored Feb 29, 2024
1 parent 1a86175 commit a809aca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/sttp/tapir/Validator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ object Validator extends ValidatorMacros {
case class All[T](validators: immutable.Seq[Validator[T]]) extends Validator[T] {
override def apply(t: T): List[ValidationError[_]] = validators.flatMap(_.apply(t)).toList

override def contramap[TT](g: TT => T): Validator[TT] = if (validators.isEmpty) All(Nil) else super.contramap(g)
override def contramap[TT](g: TT => T): Validator[TT] = if (validators.isEmpty) this.asInstanceOf[Validator[TT]] else super.contramap(g)
override def and(other: Validator[T]): Validator[T] = if (validators.isEmpty) other else All(validators :+ other)
}

Expand Down

0 comments on commit a809aca

Please sign in to comment.