Skip to content

Commit

Permalink
Merge pull request #1 from saber3005/duplicate-set-operations
Browse files Browse the repository at this point in the history
Stop redundant `set`s
  • Loading branch information
Jason-Rev committed Mar 9, 2016
2 parents 66b894a + e577335 commit e5b4e39
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/setValueFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@ function setValueByArrayPath($doc, $fieldPath, $value) {
$fieldName = array_shift($fieldPath);
$subDoc = getValue($doc, $fieldName, array());
$subDocUpdated = setValueByArrayPath($subDoc, $fieldPath, $value);
return setValue($doc, $fieldName, $subDocUpdated);
if ($subDocUpdated !== $subDoc) {
$doc = setValue($doc, $fieldName, $subDocUpdated);
}
return $doc;
}

0 comments on commit e5b4e39

Please sign in to comment.