fgerlits commented on code in PR #1354:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1354#discussion_r926620090
##########
libminifi/src/core/Processor.cpp:
##########
@@ -290,32 +289,16 @@ bool Processor::partOfCycle(Connection* conn) {
}
bool Processor::isThrottledByBackpressure() const {
- bool isThrottledByOutgoing = ([&] {
- for (auto &outIt : outgoing_connections_) {
- for (auto &out : outIt.second) {
- auto connection = dynamic_cast<Connection*>(out);
- if (!connection) {
- continue;
- }
- if (connection->isFull()) {
- return true;
- }
- }
- }
- return false;
- })();
- bool isForcedByIncomingCycle = ([&] {
- for (auto &inConn : incoming_connections_) {
- auto connection = dynamic_cast<Connection*>(inConn);
- if (!connection) {
- continue;
- }
- if (partOfCycle(connection) && connection->isFull()) {
- return true;
- }
- }
- return false;
- })();
+ bool isThrottledByOutgoing = ranges::any_of(outgoing_connections_, [&](auto&
outIt) {
+ return ranges::any_of(outIt.second, [&](auto* out) {
+ auto connection = dynamic_cast<Connection*>(out);
+ return connection && connection->isFull();
+ });
+ });
+ bool isForcedByIncomingCycle = ranges::any_of(incoming_connections_,
[&](auto& inConn) {
+ auto connection = dynamic_cast<Connection*>(inConn);
+ return connection && partOfCycle(connection) && connection->isFull();
+ });
Review Comment:
This looks nice; just a few nitpicks:
* `outIt` is not an iterator; it should be `kv`, `key_value_pair`,
`name_connection_set_pair` or similar
* I don't think any of these 3 lambdas need to capture anything
* the type of the parameters in lines 293 and 298 should be the same, and
their names more similar.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]