Skip to content

Commit fef6694

Browse files
refactor: use Set for O(1) lookup when filtering collection parents in bulk delete
Signed-off-by: Valentijn Scholten <valentijnscholten@gmail.com>
1 parent a1aeb30 commit fef6694

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/main/java/org/dependencytrack/persistence/ProjectQueryManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,11 +1037,12 @@ public void deleteProjectsByUUIDs(Collection<UUID> uuids) {
10371037

10381038
// Collect parent collection projects that need metrics updates after deletion.
10391039
// Exclude parents that are themselves being deleted.
1040+
final Set<UUID> deleteUuids = uuids instanceof Set ? (Set<UUID>) uuids : Set.copyOf(uuids);
10401041
final Set<UUID> collectionParentUuids = projects.stream()
10411042
.map(Project::getParent)
10421043
.filter(parent -> parent != null
10431044
&& parent.getCollectionLogic() != ProjectCollectionLogic.NONE
1044-
&& uuids.stream().noneMatch(u -> u.equals(parent.getUuid())))
1045+
&& !deleteUuids.contains(parent.getUuid()))
10451046
.map(Project::getUuid)
10461047
.collect(Collectors.toSet());
10471048

0 commit comments

Comments
 (0)