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; }