java-topology/defects/redmine/patch/redmine-0002-issue-would_reschedule-bfs-array.patch

26 lines
854 B
Diff

# UNDF: UNDF-2026-000000877
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1352,7 +1352,7 @@
# Returns true if the other issue might be rescheduled if the start/due dates of this issue change
def would_reschedule?(other)
- all = [self]
+ all = Set.new([self]) # Use Set for O(1) membership instead of Array O(N)
last = [self]
while last.any?
current = last.map do |i|
@@ -1360,10 +1360,9 @@
i.leaves.to_a +
i.ancestors.map {|a| a.relations_from.where(:relation_type => IssueRelation::TYPE_PRECEDES).map(&:issue_to)}
end.flatten.uniq
- current -= last
- current -= all
+ current.reject! { |c| all.include?(c) } # O(1) per element with Set
return true if current.include?(other)
last = current
- all += last
+ all.merge(last)
end
false
end