From 8ad949a995d3b0d6507f74cb5cb2f5dd56246b0e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 4 Sep 2022 07:07:55 -0400 Subject: [PATCH] avoid extra char * to std::string conversion --- src/atom.cpp | 12 ++++++------ src/molecule.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 5c60226cdf..3444093f30 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1192,7 +1192,7 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset, switch (utils::is_type(typestr)) { case 0: { // numeric - int itype = utils::inumeric(FLERR, typestr.c_str(), true, lmp); + int itype = utils::inumeric(FLERR, typestr, true, lmp); if ((itype < 1) || (itype > ntypes)) error->one(FLERR, "Invalid atom type {} in {}: {}", itype, location, utils::trim(buf)); @@ -1304,7 +1304,7 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset, switch (utils::is_type(typestr)) { case 0: { // numeric - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); if ((itype < 1) || (itype > nbondtypes)) error->all(FLERR, "Invalid bond type {} in {}: {}", itype, location, utils::trim(buf)); if (labelflag) itype = ilabel[itype - 1]; @@ -1403,7 +1403,7 @@ void Atom::data_angles(int n, char *buf, int *count, tagint id_offset, switch (utils::is_type(typestr)) { case 0: { // numeric - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); if ((itype < 1) || (itype > nangletypes)) error->all(FLERR, "Invalid angle type {} in {}: {}", itype, location, utils::trim(buf)); if (labelflag) itype = ilabel[itype - 1]; @@ -1518,7 +1518,7 @@ void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset, switch (utils::is_type(typestr)) { case 0: { // numeric - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); if ((itype < 1) || (itype > ndihedraltypes)) error->all(FLERR, "Invalid dihedral type {} in {}: {}", itype, location, utils::trim(buf)); @@ -1650,7 +1650,7 @@ void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset, switch (utils::is_type(typestr)) { case 0: { // numeric - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); if ((itype < 1) || (itype > nimpropertypes)) error->all(FLERR, "Invalid improper type {} in {}: {}", itype, location, utils::trim(buf)); @@ -1944,7 +1944,7 @@ void Atom::set_mass(const char *file, int line, int /*narg*/, char **arg) case 0: { // numeric int lo, hi; - utils::bounds(file, line, typestr.c_str(), 1, ntypes, lo, hi, error); + utils::bounds(file, line, typestr, 1, ntypes, lo, hi, error); if ((lo < 1) || (hi > ntypes)) error->all(file, line, "Invalid atom type {} for atom mass", typestr); diff --git a/src/molecule.cpp b/src/molecule.cpp index a1583fc0c0..93bd114fec 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -770,7 +770,7 @@ void Molecule::types(char *line) type[iatom] = atom->lmap->find(typestr, Atom::ATOM); if (type[iatom] == -1) error->one(FLERR, "Invalid Types section in molecule file"); } else - type[iatom] = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + type[iatom] = utils::inumeric(FLERR, typestr, false, lmp); type[iatom] += toffset; } } catch (TokenizerException &e) { @@ -1002,7 +1002,7 @@ void Molecule::bonds(int flag, char *line) itype = atom->lmap->find(typestr, Atom::BOND); if (itype == -1) error->one(FLERR, "Invalid Bonds section in molecule file"); } else - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); atom1 = values.next_tagint(); atom2 = values.next_tagint(); } catch (TokenizerException &e) { @@ -1075,7 +1075,7 @@ void Molecule::angles(int flag, char *line) itype = atom->lmap->find(typestr, Atom::ANGLE); if (itype == -1) error->one(FLERR, "Invalid Angles section in molecule file"); } else - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); atom1 = values.next_tagint(); atom2 = values.next_tagint(); atom3 = values.next_tagint(); @@ -1164,7 +1164,7 @@ void Molecule::dihedrals(int flag, char *line) itype = atom->lmap->find(typestr, Atom::DIHEDRAL); if (itype == -1) error->one(FLERR, "Invalid Dihedrals section in molecule file"); } else - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); atom1 = values.next_tagint(); atom2 = values.next_tagint(); atom3 = values.next_tagint(); @@ -1267,7 +1267,7 @@ void Molecule::impropers(int flag, char *line) itype = atom->lmap->find(typestr, Atom::IMPROPER); if (itype == -1) error->one(FLERR, "Invalid Impropers section in molecule file"); } else - itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); + itype = utils::inumeric(FLERR, typestr, false, lmp); atom1 = values.next_tagint(); atom2 = values.next_tagint(); atom3 = values.next_tagint();