Skip to content

Commit b47683d

Browse files
committed
Do not create child collectors for flag output once the failid result is determinated
1 parent f84194e commit b47683d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/commonMain/kotlin/io/github/optimumcode/json/schema/OutputCollector.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ public sealed class OutputCollector<T> private constructor(
185185
hasErrors = true
186186
}
187187

188-
override fun childCollector(): Flag = Flag(this)
188+
override fun childCollector(): Flag =
189+
// once `valid` flag is set to false we can avoid creating child collectors
190+
// because the validation result won't be changed
191+
if (valid) Flag(this) else this
189192
}
190193

191194
private class Basic(

0 commit comments

Comments
 (0)