Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
avoid potential division by 0... But not sure 0 is right as an answer here
[simgrid.git] / src / xbt / xbt_replay.cpp
index 9571091..beee5cd 100644 (file)
@@ -38,6 +38,7 @@ public:
     fs = new std::ifstream(filename, std::ifstream::in);
     xbt_assert(fs->is_open(), "Cannot read replay file '%s'", filename);
   }
+  ReplayReader(const ReplayReader&) = delete;
   ~ReplayReader()
   {
     delete fs;
@@ -78,9 +79,10 @@ static ReplayAction* get_action(char* name)
       } else {
         // Else, I have to store it for the relevant colleague
         std::queue<ReplayAction*>* otherqueue = nullptr;
-        try {
-          otherqueue = action_queues.at(evtname);
-        } catch (std::out_of_range& unfound) { // Damn. Create the queue of that guy
+        auto act                              = action_queues.find(evtname);
+        if (act != action_queues.end()) {
+          otherqueue = act->second;
+        } else { // Damn. Create the queue of that guy
           otherqueue = new std::queue<ReplayAction*>();
           action_queues.insert({evtname, otherqueue});
         }
@@ -103,7 +105,7 @@ static void handle_action(ReplayAction* action)
   char** c_action     = new char*[action->size() + 1];
   action_fun function = action_funs.at(action->at(1));
   int i               = 0;
-  for (auto arg : *action) {
+  for (auto const& arg : *action) {
     c_action[i] = xbt_strdup(arg.c_str());
     i++;
   }