From d820e6777aef9556c355e183be64032ad269f5b8 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 23 Jul 2019 14:33:35 -0500 Subject: [PATCH] Apply suggestions from code review Accessing cell/material names through accessor. Returning a const reference from `name()` accessor in both cases. Co-Authored-By: Paul Romano --- include/openmc/cell.h | 2 +- include/openmc/material.h | 2 +- src/cell.cpp | 2 +- src/material.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 752945ceec..602da98e7a 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -136,7 +136,7 @@ public: //! Get the name of a cell //! \return Cell name - std::string name() const { return name_; }; + const std::string& name() const { return name_; }; //! Set the temperature of a cell instance //! \param[in] name Cell name diff --git a/include/openmc/material.h b/include/openmc/material.h index aa0a4bad0a..652f3db8e1 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -94,7 +94,7 @@ public: //! Get name //! \return Material name - std::string name() const { return name_; } + const std::string& name() const { return name_; } //! Set name void set_name(const std::string& name) { name_ = name; } diff --git a/src/cell.cpp b/src/cell.cpp index 7cc74ed9f3..49d8cb1b41 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -1089,7 +1089,7 @@ openmc_cell_get_name(int32_t index, const char** name) { return OPENMC_E_OUT_OF_BOUNDS; } - *name = model::cells[index]->name_.data(); + *name = model::cells[index]->name().data(); return 0; } diff --git a/src/material.cpp b/src/material.cpp index 699649d31c..685fd1da2e 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1388,7 +1388,7 @@ openmc_material_get_name(int32_t index, const char** name) { return OPENMC_E_OUT_OF_BOUNDS; } - *name = model::materials[index]->name_.data(); + *name = model::materials[index]->name().data(); return 0; }