Skip to content

Commit

Permalink
Update bestTask() to select CERTs with priority
Browse files Browse the repository at this point in the history
  • Loading branch information
preda committed Oct 29, 2024
1 parent c01cab8 commit 9c8a2b8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Worktodo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ std::optional<Task> parse(const std::string& line) {
return {};
}

// Among the valid tasks from fileName, return the "best" which means with the smallest exponent
// Among the valid tasks from fileName, return the "best" which means the smallest CERT, or otherwise the exponent PRP/LL
static std::optional<Task> bestTask(const fs::path& fileName) {
optional<Task> best;
for (const string& line : File::openRead(fileName)) {
optional<Task> task = parse(line);
if (task && (!best || task->exponent < best->exponent)) { best = task; }
if (task && (!best
|| (best->kind != Task::CERT && task->kind == Task::CERT)
|| ((best->kind != Task::CERT || task->kind == Task::CERT) && task->exponent < best->exponent))) {
best = task;
}
}
return best;
}
Expand Down

0 comments on commit 9c8a2b8

Please sign in to comment.