From 7e025feb1fe84c553243a1f52dc5a2a7f48bc67e Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 27 Oct 2020 23:03:19 +0100 Subject: [PATCH] Make trivial functions inline. --- src/smpi/include/smpi_f2c.hpp | 54 +++++++++++++++++------------------ src/smpi/mpi/smpi_f2c.cpp | 32 --------------------- 2 files changed, 27 insertions(+), 59 deletions(-) diff --git a/src/smpi/include/smpi_f2c.hpp b/src/smpi/include/smpi_f2c.hpp index 7acafc0ef9..69c309d33e 100644 --- a/src/smpi/include/smpi_f2c.hpp +++ b/src/smpi/include/smpi_f2c.hpp @@ -15,33 +15,33 @@ namespace simgrid{ namespace smpi{ class F2C { - private: - // We use a single lookup table for every type. - // Beware of collisions if id in mpif.h is not unique - static std::unordered_map* f2c_lookup_; - static int f2c_id_; - int my_f2c_id_ = -1; - - protected: - static std::unordered_map* f2c_lookup(); - static void set_f2c_lookup(std::unordered_map* map); - static int f2c_id(); - static void f2c_id_increment(); - - public: - static void delete_lookup(); - static std::unordered_map* lookup(); - F2C(); - virtual ~F2C() = default; - - //Override these to handle specific values. - virtual int add_f(); - static void free_f(int id); - virtual int c2f(); - static void print_f2c_lookup(); - // This method should be overridden in all subclasses to avoid casting the result when calling it. - // For the default one, the MPI_*_NULL returned is assumed to be NULL. - static F2C* f2c(int id); +private: + // We use a single lookup table for every type. + // Beware of collisions if id in mpif.h is not unique + static std::unordered_map* f2c_lookup_; + static int f2c_id_; + int my_f2c_id_ = -1; + +protected: + static std::unordered_map* f2c_lookup() { return f2c_lookup_; } + static void set_f2c_lookup(std::unordered_map* map) { f2c_lookup_ = map; } + static int f2c_id() { return f2c_id_; } + static void f2c_id_increment() { f2c_id_++; } + +public: + static void delete_lookup() { delete f2c_lookup_; } + static std::unordered_map* lookup() { return f2c_lookup_; } + F2C(); + virtual ~F2C() = default; + + // Override these to handle specific values. + virtual int add_f(); + static void free_f(int id) { f2c_lookup_->erase(id); } + virtual int c2f(); + static void print_f2c_lookup(); + // This method should be overridden in all subclasses to avoid casting the result when calling it. + // For the default one, the MPI_*_NULL returned is assumed to be NULL. + static F2C* f2c(int id); }; } diff --git a/src/smpi/mpi/smpi_f2c.cpp b/src/smpi/mpi/smpi_f2c.cpp index bff67c385f..1989c1255d 100644 --- a/src/smpi/mpi/smpi_f2c.cpp +++ b/src/smpi/mpi/smpi_f2c.cpp @@ -21,38 +21,6 @@ int F2C::f2c_id_ = 0; // Keep it non trivially-constructible, or it will break MC+smpi on FreeBSD with Clang (don't ask why) F2C::F2C() = default; -std::unordered_map* F2C::f2c_lookup() -{ - return f2c_lookup_; -} - -void F2C::set_f2c_lookup(std::unordered_map* map) -{ - f2c_lookup_ = map; -} - -void F2C::f2c_id_increment(){ - f2c_id_++; -} - -int F2C::f2c_id(){ - return f2c_id_; -} - -void F2C::delete_lookup(){ - delete f2c_lookup_; -} - -std::unordered_map* F2C::lookup() -{ - return f2c_lookup_; -} - -void F2C::free_f(int id) -{ - f2c_lookup_->erase(id); -} - int F2C::add_f() { if (f2c_lookup_ == nullptr) -- 2.20.1