Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make mc::Api::get_actor_name return a const&.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 2 Apr 2021 07:55:05 +0000 (09:55 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 2 Apr 2021 08:04:45 +0000 (10:04 +0200)
Sometimes avoids unnecessary copies.

src/mc/api.cpp
src/mc/api.hpp
src/mc/remote/RemoteProcess.hpp

index d9e32e9..ec0b7e3 100644 (file)
@@ -379,7 +379,7 @@ xbt::string const& Api::get_actor_host_name(smx_actor_t actor) const
   return *info->hostname;
 }
 
-std::string Api::get_actor_name(smx_actor_t actor) const
+xbt::string const& Api::get_actor_name(smx_actor_t actor) const
 {
   if (mc_model_checker == nullptr)
     return actor->get_name();
@@ -400,7 +400,7 @@ std::string Api::get_actor_string(smx_actor_t actor) const
   if (actor) {
     res = "(" + std::to_string(actor->get_pid()) + ")";
     if (actor->get_host())
-      res += std::string(get_actor_host_name(actor)) + " (" + get_actor_name(actor) + ")";
+      res += std::string(get_actor_host_name(actor)) + " (" + std::string(get_actor_name(actor)) + ")";
     else
       res += get_actor_name(actor);
   } else
index f3df834..548bbe8 100644 (file)
@@ -78,7 +78,7 @@ public:
   unsigned long get_pattern_comm_src_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const;
   unsigned long get_pattern_comm_dst_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const;
   std::vector<char> get_pattern_comm_data(RemotePtr<kernel::activity::CommImpl> const& addr) const;
-  std::string get_actor_name(smx_actor_t actor) const;
+  xbt::string const& get_actor_name(smx_actor_t actor) const;
   xbt::string const& get_actor_host_name(smx_actor_t actor) const;
 #if HAVE_SMPI
   bool check_send_request_detached(smx_simcall_t const& simcall) const;
index 2530d13..19df383 100644 (file)
@@ -27,7 +27,7 @@ public:
 
   /** Hostname (owned by `mc_model_checker->hostnames_`) */
   const xbt::string* hostname = nullptr;
-  std::string name;
+  xbt::string name;
 
   void clear()
   {