Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
stringification
[simgrid.git] / src / surf / FileImpl.cpp
index 5354850..fbb70a7 100644 (file)
@@ -17,9 +17,10 @@ FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_
   location_ = st->getImpl();
   std::map<std::string, sg_size_t>* content = location_->getContent();
   // if file does not exist create an empty file
-  if (content->find(path) != content->end())
-    size_ = content->at(path);
-  else {
+  auto sz = content->find(path);
+  if (sz != content->end()) {
+    size_ = sz->second;
+  } else {
     size_ = 0;
     content->insert({path, size_});
     XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
@@ -96,8 +97,9 @@ void FileImpl::move(const char* fullpath)
   /* Check if the new full path is on the same mount point */
   if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) {
     std::map<std::string, sg_size_t>* content = location_->getContent();
-    if (content->find(path_) != content->end()) { // src file exists
-      sg_size_t new_size = content->at(path_);
+    auto sz = content->find(path_);
+    if (sz != content->end()) { // src file exists
+      sg_size_t new_size = sz->second;
       content->erase(path_);
       std::string path = std::string(fullpath).substr(mount_point_.size(), strlen(fullpath));
       content->insert({path.c_str(), new_size});