avoid extra char * to std::string conversion

This commit is contained in:
Axel Kohlmeyer
2022-09-04 07:07:55 -04:00
parent 26e1b7c44d
commit 8ad949a995
2 changed files with 11 additions and 11 deletions

View File

@ -1192,7 +1192,7 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
switch (utils::is_type(typestr)) { switch (utils::is_type(typestr)) {
case 0: { // numeric 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)) if ((itype < 1) || (itype > ntypes))
error->one(FLERR, "Invalid atom type {} in {}: {}", itype, location, error->one(FLERR, "Invalid atom type {} in {}: {}", itype, location,
utils::trim(buf)); 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)) { switch (utils::is_type(typestr)) {
case 0: { // numeric case 0: { // numeric
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
if ((itype < 1) || (itype > nbondtypes)) if ((itype < 1) || (itype > nbondtypes))
error->all(FLERR, "Invalid bond type {} in {}: {}", itype, location, utils::trim(buf)); error->all(FLERR, "Invalid bond type {} in {}: {}", itype, location, utils::trim(buf));
if (labelflag) itype = ilabel[itype - 1]; 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)) { switch (utils::is_type(typestr)) {
case 0: { // numeric case 0: { // numeric
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
if ((itype < 1) || (itype > nangletypes)) if ((itype < 1) || (itype > nangletypes))
error->all(FLERR, "Invalid angle type {} in {}: {}", itype, location, utils::trim(buf)); error->all(FLERR, "Invalid angle type {} in {}: {}", itype, location, utils::trim(buf));
if (labelflag) itype = ilabel[itype - 1]; 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)) { switch (utils::is_type(typestr)) {
case 0: { // numeric case 0: { // numeric
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
if ((itype < 1) || (itype > ndihedraltypes)) if ((itype < 1) || (itype > ndihedraltypes))
error->all(FLERR, "Invalid dihedral type {} in {}: {}", itype, location, error->all(FLERR, "Invalid dihedral type {} in {}: {}", itype, location,
utils::trim(buf)); 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)) { switch (utils::is_type(typestr)) {
case 0: { // numeric case 0: { // numeric
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
if ((itype < 1) || (itype > nimpropertypes)) if ((itype < 1) || (itype > nimpropertypes))
error->all(FLERR, "Invalid improper type {} in {}: {}", itype, location, error->all(FLERR, "Invalid improper type {} in {}: {}", itype, location,
utils::trim(buf)); utils::trim(buf));
@ -1944,7 +1944,7 @@ void Atom::set_mass(const char *file, int line, int /*narg*/, char **arg)
case 0: { // numeric case 0: { // numeric
int lo, hi; 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)) if ((lo < 1) || (hi > ntypes))
error->all(file, line, "Invalid atom type {} for atom mass", typestr); error->all(file, line, "Invalid atom type {} for atom mass", typestr);

View File

@ -770,7 +770,7 @@ void Molecule::types(char *line)
type[iatom] = atom->lmap->find(typestr, Atom::ATOM); type[iatom] = atom->lmap->find(typestr, Atom::ATOM);
if (type[iatom] == -1) error->one(FLERR, "Invalid Types section in molecule file"); if (type[iatom] == -1) error->one(FLERR, "Invalid Types section in molecule file");
} else } else
type[iatom] = utils::inumeric(FLERR, typestr.c_str(), false, lmp); type[iatom] = utils::inumeric(FLERR, typestr, false, lmp);
type[iatom] += toffset; type[iatom] += toffset;
} }
} catch (TokenizerException &e) { } catch (TokenizerException &e) {
@ -1002,7 +1002,7 @@ void Molecule::bonds(int flag, char *line)
itype = atom->lmap->find(typestr, Atom::BOND); itype = atom->lmap->find(typestr, Atom::BOND);
if (itype == -1) error->one(FLERR, "Invalid Bonds section in molecule file"); if (itype == -1) error->one(FLERR, "Invalid Bonds section in molecule file");
} else } else
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
atom1 = values.next_tagint(); atom1 = values.next_tagint();
atom2 = values.next_tagint(); atom2 = values.next_tagint();
} catch (TokenizerException &e) { } catch (TokenizerException &e) {
@ -1075,7 +1075,7 @@ void Molecule::angles(int flag, char *line)
itype = atom->lmap->find(typestr, Atom::ANGLE); itype = atom->lmap->find(typestr, Atom::ANGLE);
if (itype == -1) error->one(FLERR, "Invalid Angles section in molecule file"); if (itype == -1) error->one(FLERR, "Invalid Angles section in molecule file");
} else } else
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
atom1 = values.next_tagint(); atom1 = values.next_tagint();
atom2 = values.next_tagint(); atom2 = values.next_tagint();
atom3 = 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); itype = atom->lmap->find(typestr, Atom::DIHEDRAL);
if (itype == -1) error->one(FLERR, "Invalid Dihedrals section in molecule file"); if (itype == -1) error->one(FLERR, "Invalid Dihedrals section in molecule file");
} else } else
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
atom1 = values.next_tagint(); atom1 = values.next_tagint();
atom2 = values.next_tagint(); atom2 = values.next_tagint();
atom3 = 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); itype = atom->lmap->find(typestr, Atom::IMPROPER);
if (itype == -1) error->one(FLERR, "Invalid Impropers section in molecule file"); if (itype == -1) error->one(FLERR, "Invalid Impropers section in molecule file");
} else } else
itype = utils::inumeric(FLERR, typestr.c_str(), false, lmp); itype = utils::inumeric(FLERR, typestr, false, lmp);
atom1 = values.next_tagint(); atom1 = values.next_tagint();
atom2 = values.next_tagint(); atom2 = values.next_tagint();
atom3 = values.next_tagint(); atom3 = values.next_tagint();