Skip to content

Commit 1844b3e

Browse files
authored
perf: remove unnecessary extra child traversal in collectDirtyChildren (#1058)
1 parent 7cff2ae commit 1844b3e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

parse/src/main/java/com/parse/ParseObject.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,9 @@ protected boolean visit(Object node) {
590590
// Check for cycles of new objects. Any such cycle means it will be
591591
// impossible to save this collection of objects, so throw an exception.
592592
if (object.getObjectId() != null) {
593-
seenNew = new HashSet<>();
593+
if (!seenNew.isEmpty()) {
594+
seenNew = new HashSet<>();
595+
}
594596
} else {
595597
if (seenNew.contains(object)) {
596598
throw new RuntimeException("Found a circular dependency while saving.");
@@ -605,7 +607,6 @@ protected boolean visit(Object node) {
605607
if (seen.contains(object)) {
606608
return true;
607609
}
608-
seen = new HashSet<>(seen);
609610
seen.add(object);
610611

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

0 commit comments

Comments
 (0)