Skip to content

Commit c7460a1

Browse files
committed
Improve performance - don't loop over everything if already valid
1 parent b8d2611 commit c7460a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/JsonSchema/Constraints/TypeConstraint.php

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public function check(&$value = null, $schema = null, JsonPointer $path = null,
8282
protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
8383
{
8484
foreach ($type as $tp) {
85+
// already valid, so no need to waste cycles looping over everything
86+
if ($isValid) {
87+
return;
88+
}
89+
8590
// $tp can be an object, if it's a schema instead of a simple type, validate it
8691
// with a new type constraint
8792
if (is_object($tp)) {

0 commit comments

Comments
 (0)