Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Constify.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 10 Mar 2019 14:46:37 +0000 (15:46 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 11 Mar 2019 08:17:20 +0000 (09:17 +0100)
include/simgrid/kernel/resource/Action.hpp
include/xbt/config.hpp
include/xbt/file.hpp
src/instr/instr_paje_containers.hpp
src/instr/instr_paje_events.cpp
src/instr/instr_paje_types.hpp
src/instr/instr_private.hpp

index 6ce0e7c..0acd6b5 100644 (file)
@@ -180,7 +180,7 @@ public:
   virtual void set_max_duration(double duration);
 
   /** @brief Get the tracing category associated to the current action */
   virtual void set_max_duration(double duration);
 
   /** @brief Get the tracing category associated to the current action */
-  std::string get_category() const { return category_; }
+  const std::string& get_category() const { return category_; }
   /** @brief Set the tracing category of the current Action */
   void set_category(std::string category) { category_ = std::move(category); }
 
   /** @brief Set the tracing category of the current Action */
   void set_category(std::string category) { category_ = std::move(category); }
 
index fed58c9..9bb3619 100644 (file)
@@ -278,7 +278,7 @@ public:
   T& get() { return value_; }
   T const& get() const { return value_; }
 
   T& get() { return value_; }
   T const& get() const { return value_; }
 
-  std::string get_name() const { return name_; }
+  const std::string& get_name() const { return name_; }
   // Implicit conversion to the underlying type:
   operator T&() { return value_; }
   operator T const&() const{ return value_; }
   // Implicit conversion to the underlying type:
   operator T&() { return value_; }
   operator T const&() const{ return value_; }
index 91c285b..4ef6c04 100644 (file)
@@ -22,7 +22,7 @@ public:
   explicit Path(std::string path): path_(std::move(path)) {}
 
   /** @brief Returns the full path name */
   explicit Path(std::string path): path_(std::move(path)) {}
 
   /** @brief Returns the full path name */
-  std::string get_name() { return path_; }
+  const std::string& get_name() const { return path_; }
   /** @brief Returns the directory component of a path (reimplementation of POSIX dirname) */
   std::string get_dir_name();
   /** @brief Returns the file component of a path (reimplementation of POSIX basename) */
   /** @brief Returns the directory component of a path (reimplementation of POSIX dirname) */
   std::string get_dir_name();
   /** @brief Returns the file component of a path (reimplementation of POSIX basename) */
index da60460..0e49398 100644 (file)
@@ -32,7 +32,7 @@ public:
 
   static Container* by_name_or_null(const std::string& name);
   static Container* by_name(const std::string& name);
 
   static Container* by_name_or_null(const std::string& name);
   static Container* by_name(const std::string& name);
-  std::string get_name() { return name_; }
+  const std::string& get_name() const { return name_; }
   const char* get_cname() { return name_.c_str(); }
   long long int get_id() { return id_; }
   void remove_from_parent();
   const char* get_cname() { return name_.c_str(); }
   long long int get_id() { return id_; }
   void remove_from_parent();
index 3ee840a..0870bf0 100644 (file)
@@ -107,12 +107,13 @@ void StateEvent::print()
     /* Unimplemented calls are: WAITANY, SENDRECV, SCAN, EXSCAN, SSEND, and ISSEND. */
 
     // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
     /* Unimplemented calls are: WAITANY, SENDRECV, SCAN, EXSCAN, SSEND, and ISSEND. */
 
     // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
-    if (get_container()->get_name().find("rank-") != 0)
+    if (get_container()->get_name().find("rank-") != 0) {
       stream_ << get_container()->get_name() << " " << extra_->print();
       stream_ << get_container()->get_name() << " " << extra_->print();
-    else
+    } else {
       /* Subtract -1 because this is the process id and we transform it to the rank id */
       /* Subtract -1 because this is the process id and we transform it to the rank id */
-      stream_ << stoi(get_container()->get_name().erase(0, 5)) - 1 << " " << extra_->print();
-
+      std::string container_name(get_container()->get_name());
+      stream_ << stoi(container_name.erase(0, 5)) - 1 << " " << extra_->print();
+    }
     *tracing_files.at(get_container()) << stream_.str() << std::endl;
   } else {
     THROW_IMPOSSIBLE;
     *tracing_files.at(get_container()) << stream_.str() << std::endl;
   } else {
     THROW_IMPOSSIBLE;
index 21a440a..47ed87c 100644 (file)
@@ -30,7 +30,7 @@ public:
   Type(std::string name, std::string alias, std::string color, Type* father);
   virtual ~Type();
 
   Type(std::string name, std::string alias, std::string color, Type* father);
   virtual ~Type();
 
-  std::string get_name() { return name_; }
+  const std::string& get_name() const { return name_; }
   const char* get_cname() { return name_.c_str(); }
   long long int get_id() { return id_; }
   bool is_colored() { return not color_.empty(); }
   const char* get_cname() { return name_.c_str(); }
   long long int get_id() { return id_; }
   bool is_colored() { return not color_.empty(); }
index e34187c..ca0119c 100644 (file)
@@ -95,7 +95,7 @@ public:
 
   virtual ~TIData() {}
 
 
   virtual ~TIData() {}
 
-  std::string getName() { return name_; }
+  const std::string& getName() const { return name_; }
   double getAmount() { return amount_; }
   virtual std::string print()        = 0;
   virtual std::string display_size() = 0;
   double getAmount() { return amount_; }
   virtual std::string print()        = 0;
   virtual std::string display_size() = 0;