]> AND Public Git Repository - simgrid.git/blobdiff - examples/cpp/app-bittorrent/s4u-peer.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix more sonar things
[simgrid.git] / examples / cpp / app-bittorrent / s4u-peer.cpp
index 9bc67ba502abe8d4b82aaba352e7f4c34f17af3a..7de17e9023b36258aa83e0a241e788d9c66d3970 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -234,11 +234,8 @@ unsigned int Peer::countPieces(unsigned int bitfield) const
 
 int Peer::nbInterestedPeers() const
 {
-  int nb = 0;
-  for (auto const& kv : connected_peers)
-    if (kv.second.interested)
-      nb++;
-  return nb;
+  return static_cast<int>(std::count_if(connected_peers.begin(), connected_peers.end(),
+                                        [](const auto& kv) { return kv.second.interested; }));
 }
 
 void Peer::leech()