Skip to content

Commit

Permalink
perf: remove unnecessary extra child traversal in collectDirtyChildren (
Browse files Browse the repository at this point in the history
  • Loading branch information
shlusiak committed Nov 3, 2021
1 parent 7cff2ae commit 1844b3e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions parse/src/main/java/com/parse/ParseObject.java
Expand Up @@ -590,7 +590,9 @@ protected boolean visit(Object node) {
// Check for cycles of new objects. Any such cycle means it will be
// impossible to save this collection of objects, so throw an exception.
if (object.getObjectId() != null) {
seenNew = new HashSet<>();
if (!seenNew.isEmpty()) {
seenNew = new HashSet<>();
}
} else {
if (seenNew.contains(object)) {
throw new RuntimeException("Found a circular dependency while saving.");
Expand All @@ -605,7 +607,6 @@ protected boolean visit(Object node) {
if (seen.contains(object)) {
return true;
}
seen = new HashSet<>(seen);
seen.add(object);

// Recurse into this object's children looking for dirty children.
Expand Down

0 comments on commit 1844b3e

Please sign in to comment.