proper fix

This commit is contained in:
Laurent Perron
2025-06-11 12:48:56 +02:00
parent 474b5c337f
commit 0ca1d9b8d8

View File

@@ -1103,7 +1103,13 @@ std::string CompletionTimeEvent::DebugString() const {
void CtExhaustiveHelper::Init(
const absl::Span<const CompletionTimeEvent> events, Model* model) {
max_task_index_ = 0;
if (events.empty() || events.size() > 100) return;
if (events.empty()) return;
// We compute the max_task_index_ from the events early to avoid sorting
// the events if there are too many of them.
for (const auto& event : events) {
max_task_index_ = std::max(max_task_index_, event.task_index);
}
if (events.size() > 100) return;
BinaryRelationsMaps* binary_relations =
model->GetOrCreate<BinaryRelationsMaps>();
@@ -1113,10 +1119,9 @@ void CtExhaustiveHelper::Init(
[](const CompletionTimeEvent& a, const CompletionTimeEvent& b) {
return a.task_index < b.task_index;
});
max_task_index_ = sorted_events.back().task_index;
predecessors_.reserve(max_task_index_ + 1);
for (const auto& e1 : events) {
for (const auto& e2 : events) {
for (const auto& e1 : sorted_events) {
for (const auto& e2 : sorted_events) {
if (e2.task_index == e1.task_index) continue;
if (binary_relations->GetLevelZeroPrecedenceStatus(e2.end, e1.start) ==
RelationStatus::IS_TRUE) {