Skip to content

Commit

Permalink
Micro-optimize flattenNotEmpty (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoepelman authored Nov 18, 2024
1 parent 29c0ec7 commit f3fc6d3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public fun <T> List<ValidationResult<T>>.flattenNonEmpty(): ValidationResult<T>

public fun List<Invalid>.flattenNotEmpty(): Invalid {
require(isNotEmpty()) { "List<Invalid> is not allowed to be empty in flattenNonEmpty" }
return Invalid(map { it.errors }.flatten())
return Invalid(this.flatMap { it.errors })
}

public fun <T> List<ValidationResult<T>>.flattenOrValid(value: T): ValidationResult<T> =
Expand Down

0 comments on commit f3fc6d3

Please sign in to comment.