Skip to content

Commit

Permalink
avoid intermediate Vector instances
Browse files Browse the repository at this point in the history
  • Loading branch information
yanns committed Jul 22, 2024
1 parent 2fb639d commit 50371d8
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,24 +616,24 @@ object OneOfInputObjectValidator extends SchemaElementValidator {
schema: Schema[_, _],
tpe: InputObjectType[_]
): Vector[Violation] = if (tpe.astDirectives.exists(_.name == OneOfDirective.name))
tpe.fields.toVector.flatMap { field =>
tpe.fields.iterator.flatMap { field =>
val defaultValueError =
field.defaultValue.map(_ => OneOfDefaultValueField(field.name, tpe.name, None, List.empty))

val nonOptionalError = field.fieldType.isOptional match {
case false =>
Some(
OneOfMandatoryField(
field.name,
tpe.name,
None,
List.empty
)
val nonOptionalError = if (field.fieldType.isOptional) {
None
} else {
Some(
OneOfMandatoryField(
field.name,
tpe.name,
None,
List.empty
)
case true => None
)
}
Vector(defaultValueError, nonOptionalError).flatten
}
Iterator(defaultValueError, nonOptionalError).flatten
}.toVector
else Vector.empty
}

Expand Down

0 comments on commit 50371d8

Please sign in to comment.