diff --git a/src/EXTRA-DUMP/dump_yaml.cpp b/src/EXTRA-DUMP/dump_yaml.cpp index 029415164f..ec7d26af31 100644 --- a/src/EXTRA-DUMP/dump_yaml.cpp +++ b/src/EXTRA-DUMP/dump_yaml.cpp @@ -64,10 +64,10 @@ void DumpYAML::write_header(bigint ndump) if (update->ntimestep == th->get_timestep()) { thermo_data += "thermo:\n - keywords: [ "; - for (auto key : th->get_keywords()) thermo_data += fmt::format("{}, ", key); + for (const auto &key : th->get_keywords()) thermo_data += fmt::format("{}, ", key); thermo_data += "]\n - data: [ "; - for (auto val : th->get_fields()) { + for (const auto &val : th->get_fields()) { if (val.type == multitype::DOUBLE) thermo_data += fmt::format("{}, ", val.data.d); else if (val.type == multitype::INT) @@ -90,7 +90,7 @@ void DumpYAML::write_header(bigint ndump) fmt::print(fp, "natoms: {}\n", ndump); fputs("boundary: [ ", fp); - for (const auto bflag : boundary) { + for (const auto &bflag : boundary) { if (bflag == ' ') continue; fmt::print(fp, "{}, ", bflag); } diff --git a/src/NETCDF/dump_netcdf.cpp b/src/NETCDF/dump_netcdf.cpp index cb6aea16cf..8c99ff1f70 100644 --- a/src/NETCDF/dump_netcdf.cpp +++ b/src/NETCDF/dump_netcdf.cpp @@ -320,7 +320,7 @@ void DumpNetCDF::openfile() // perframe variables if (thermo) { - auto keywords = output->thermo->get_keywords(); + const auto &keywords = output->thermo->get_keywords(); int nfield = keywords.size(); for (int i = 0; i < nfield; i++) { NCERRX( nc_inq_varid(ncid, keywords[i].c_str(), &thermovar[i]), keywords[i].c_str() ); @@ -433,8 +433,8 @@ void DumpNetCDF::openfile() // perframe variables if (thermo) { - auto fields = output->thermo->get_fields(); - auto keywords = output->thermo->get_keywords(); + const auto &fields = output->thermo->get_fields(); + const auto &keywords = output->thermo->get_keywords(); int nfield = fields.size(); for (int i = 0; i < nfield; i++) { if (fields[i].type == multitype::DOUBLE) { @@ -600,8 +600,8 @@ void DumpNetCDF::write() start[1] = 0; if (thermo) { - auto keywords = output->thermo->get_keywords(); - auto fields = output->thermo->get_fields(); + const auto &keywords = output->thermo->get_keywords(); + const auto &fields = output->thermo->get_fields(); int nfield = fields.size(); for (int i = 0; i < nfield; i++) { if (filewriter) { diff --git a/src/NETCDF/dump_netcdf_mpiio.cpp b/src/NETCDF/dump_netcdf_mpiio.cpp index fdcd03470e..3aec34dd40 100644 --- a/src/NETCDF/dump_netcdf_mpiio.cpp +++ b/src/NETCDF/dump_netcdf_mpiio.cpp @@ -318,7 +318,7 @@ void DumpNetCDFMPIIO::openfile() // perframe variables if (thermo) { - auto keywords = output->thermo->get_keywords(); + const auto &keywords = output->thermo->get_keywords(); int nfield = keywords.size(); for (int i = 0; i < nfield; i++) { NCERRX( ncmpi_inq_varid(ncid, keywords[i].c_str(), &thermovar[i]), keywords[i].c_str() ); @@ -423,8 +423,8 @@ void DumpNetCDFMPIIO::openfile() // perframe variables if (thermo) { - auto fields = output->thermo->get_fields(); - auto keywords = output->thermo->get_keywords(); + const auto &fields = output->thermo->get_fields(); + const auto &keywords = output->thermo->get_keywords(); int nfield = fields.size(); for (int i = 0; i < nfield; i++) { if (fields[i].type == multitype::DOUBLE) { @@ -593,8 +593,8 @@ void DumpNetCDFMPIIO::write() NCERR( ncmpi_begin_indep_data(ncid) ); if (thermo) { - auto keywords = output->thermo->get_keywords(); - auto fields = output->thermo->get_fields(); + const auto &keywords = output->thermo->get_keywords(); + const auto &fields = output->thermo->get_fields(); int nfield = fields.size(); for (int i = 0; i < nfield; i++) { if (filewriter) {