perf: simplify for loops and lambdas, etc

This commit is contained in:
Horror Proton
2022-08-09 14:54:18 +08:00
parent 01b05fd85d
commit 08c153de3e
12 changed files with 20 additions and 61 deletions

View File

@@ -594,10 +594,8 @@ bool asst::Controller::screencap()
return false;
}
size_t header_size = data.size() - std_size;
bool is_all_zero = std::all_of(data.data() + header_size, data.data() + std_size,
[](uchar uch) -> bool {
return uch == 0;
});
bool is_all_zero =
std::all_of(data.data() + header_size, data.data() + std_size, std::logical_not<bool>{});
if (is_all_zero) {
return false;
}
@@ -621,10 +619,8 @@ bool asst::Controller::screencap()
return false;
}
size_t header_size = unzip_data.size() - std_size;
bool is_all_zero = std::all_of(unzip_data.data() + header_size, unzip_data.data() + std_size,
[](uchar uch) -> bool {
return uch == 0;
});
bool is_all_zero =
std::all_of(unzip_data.data() + header_size, unzip_data.data() + std_size, std::logical_not<bool>{});
if (is_all_zero) {
return false;
}