Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions source/MaaFramework/Task/PipelineTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,16 @@ NodeDetail PipelineTask::run_next(const std::vector<MAA_RES_NS::NodeAttr>& next,
return true;
};

const bool need_screencap = !std::ranges::all_of(next, [&](const MAA_RES_NS::NodeAttr& node) {
auto data_opt = context_->get_pipeline_data(node);
return !data_opt || !data_opt->enabled || data_opt->reco_type == MAA_RES_NS::Recognition::Type::DirectHit;
});
Comment on lines +164 to +167
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need_screencap calls context_->get_pipeline_data(node) for every entry in next, but the function is also called just above in the valid check. Because get_pipeline_data() logs warnings on missing nodes, this can double-log and also does two lookups per node. Consider iterating next once and computing both valid and need_screencap (and/or caching the resolved PipelineData/enabled/reco_type) to avoid repeated lookups/log noise.

Copilot uses AI. Check for mistakes.

while (!context_->need_to_stop()) {
auto current_clock = std::chrono::steady_clock::now();
cv::Mat image = screencap();
cv::Mat image = need_screencap ? screencap() : cv::Mat {};

if (image.empty()) {
if (need_screencap && image.empty()) {
LogWarn << "screencap failed, skip recognition" << VAR(pretask.name);
if (!check_timeout_and_sleep(current_clock)) {
break;
Expand Down
Loading