Skip to content

Commit

Permalink
avoid unnessary array_merge calls
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalkaoz committed Sep 21, 2016
1 parent 2128f9d commit 4f96ab3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/JsonSchema/Constraints/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public function addError(JsonPointer $path = null, $message, $constraint='', arr
*/
public function addErrors(array $errors)
{
$this->errors = array_merge($this->errors, $errors);
if ($errors) {
$this->errors = array_merge($this->errors, $errors);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Constraints/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function setConstraintClass($name, $class)
*/
public function createInstanceFor($constraintName)
{
if (array_key_exists($constraintName, $this->constraintMap)) {
if (isset($this->constraintMap[$constraintName])) {
if (!isset($this->instanceCache[$constraintName])) {
$this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName](
$this->checkMode,
Expand Down
1 change: 0 additions & 1 deletion src/JsonSchema/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace JsonSchema;

use JsonSchema\Constraints\SchemaConstraint;
use JsonSchema\Constraints\Constraint;
use JsonSchema\Entity\JsonPointer;

Expand Down

0 comments on commit 4f96ab3

Please sign in to comment.