Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use empty() to check for container emptiness.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 10 Jun 2021 08:19:38 +0000 (10:19 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 10 Jun 2021 09:26:04 +0000 (11:26 +0200)
examples/deprecated/java/app/bittorrent/Peer.java
src/kernel/resource/profile/Profile.cpp
src/s4u/s4u_Actor.cpp
src/smpi/internals/smpi_deployment.cpp
src/surf/cpu_interface.cpp
teshsuite/surf/surf_usage2/surf_usage2.cpp

index 83f36cc..3bd30bf 100644 (file)
@@ -395,7 +395,7 @@ public class Peer extends Process {
   // Update the list of current choked and unchoked peers, using the choke algorithm
   private void updateChokedPeers() {
     round = (round + 1) % 3;
-    if (peers.size() == 0) {
+    if (peers.isEmpty()) {
       return;
     }
     //remove a peer from the list
index 7174d92..b6167c4 100644 (file)
@@ -129,7 +129,7 @@ Profile* Profile::from_string(const std::string& name, const std::string& input,
       std::vector<std::string> splittedval((std::istream_iterator<std::string>(iss)),
                                            std::istream_iterator<std::string>());
 
-      xbt_assert(splittedval.size() > 0, "Invalid profile line");
+      xbt_assert(not splittedval.empty(), "Invalid profile line");
 
       if (splittedval[0] == "DET") {
         stochevent.date_law = Distribution::DET;
index bb548f0..5a67ebd 100644 (file)
@@ -387,7 +387,7 @@ ExecPtr exec_init(double flops_amount)
 ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
                   const std::vector<double>& bytes_amounts)
 {
-  xbt_assert(hosts.size() > 0, "Your parallel executions must span over at least one host.");
+  xbt_assert(not hosts.empty(), "Your parallel executions must span over at least one host.");
   xbt_assert(hosts.size() == flops_amounts.size() || flops_amounts.empty(),
              "Host count (%zu) does not match flops_amount count (%zu).", hosts.size(), flops_amounts.size());
   xbt_assert(hosts.size() * hosts.size() == bytes_amounts.size() || bytes_amounts.empty(),
index f2721db..93c7e61 100644 (file)
@@ -115,10 +115,10 @@ static std::vector<simgrid::s4u::Host*> smpi_get_hosts(simgrid::s4u::Engine* e,
   xbt_assert(in, "smpirun: Cannot open the host file: %s", hostfile.c_str());
   std::string str;
   while (std::getline(in, str)) {
-    if (str.size() > 0)
+    if (not str.empty())
       hosts.emplace_back(e->host_by_name(str));
   }
-  xbt_assert(hosts.size(), "smpirun: the hostfile '%s' is empty", hostfile.c_str());
+  xbt_assert(not hosts.empty(), "smpirun: the hostfile '%s' is empty", hostfile.c_str());
   return hosts;
 }
 
@@ -133,7 +133,7 @@ static std::vector<std::string> smpi_read_replay(const std::string& replayfile)
   xbt_assert(in, "smpirun: Cannot open the replay file: %s", replayfile.c_str());
   std::string str;
   while (std::getline(in, str)) {
-    if (str.size() > 0)
+    if (not str.empty())
       replay.emplace_back(str);
   }
 
@@ -146,7 +146,7 @@ static std::vector<std::string> smpi_deployment_get_args(int rank_id, const std:
 {
   std::vector<std::string> args{std::to_string(rank_id)};
   // pass arguments to process only if not a replay execution
-  if (replay.size() == 0) {
+  if (replay.empty()) {
     for (int i = 0; i < argc; i++) {
       args.push_back(argv[i]);
     }
@@ -190,7 +190,7 @@ int smpi_deployment_smpirun(simgrid::s4u::Engine* e, const std::string& hostfile
     }
     actor->set_property("instance_id", "smpirun");
     actor->set_property("rank", rank_id);
-    if (replay.size() > 0)
+    if (not replay.empty())
       actor->set_property("smpi_replay", "true");
     /* shared trace file, set it to rank 0 */
     if (i == 0 && replay.size() == 1)
index 24f37a8..8a9a5c1 100644 (file)
@@ -82,7 +82,7 @@ CpuImpl* CpuImpl::set_pstate(int pstate_index)
 
 CpuImpl* CpuImpl::set_pstate_speed(const std::vector<double>& speed_per_state)
 {
-  xbt_assert(speed_per_state.size() > 0, "CPU %s: processor speed vector cannot be empty", get_cname());
+  xbt_assert(not speed_per_state.empty(), "CPU %s: processor speed vector cannot be empty", get_cname());
   xbt_assert(not is_sealed(), "CPU %s: processor speed cannot be changed once CPU has been sealed", get_cname());
   speed_per_pstate_ = speed_per_state;
   speed_.peak       = speed_per_pstate_.front();
index c79d19b..e52a0e4 100644 (file)
@@ -51,7 +51,7 @@ int main(int argc, char** argv)
     XBT_INFO("Next Event : %g", now);
 
     for (auto const& model : simgrid::kernel::EngineImpl::get_instance()->get_all_models()) {
-      if (model->get_started_action_set()->size() != 0) {
+      if (not model->get_started_action_set()->empty()) {
         XBT_DEBUG("\t Running that model");
         running = 1;
       }