Skip to content

Commit

Permalink
Optimize using find_if_not()
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Sep 8, 2023
1 parent a1fbca9 commit 567467e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions cpp/piscsi/piscsi_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,8 @@ string PiscsiExecutor::ValidateLunSetup(const PbCommand& command) const
}

// LUN 0 must exist for all devices
for (const auto& [id, lun]: luns) {
if (!(lun & 0x01)) {
return "LUN 0 is missing for device ID " + to_string(id);
}
}

return "";
const auto& it = ranges::find_if_not(luns, [] (const auto& l) { return l.second & 0x01; } );
return it == luns.end() ? "" : "LUN 0 is missing for device ID " + to_string((*it).first);
}

bool PiscsiExecutor::VerifyExistingIdAndLun(const CommandContext& context, int id, int lun) const
Expand Down

0 comments on commit 567467e

Please sign in to comment.