passing strings by reference
This commit is contained in:
@ -172,7 +172,7 @@ void LabelMap::create_lmap2lmap(LabelMap *lmap2, int mode)
|
||||
return numeric type
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int LabelMap::find_or_create(std::string mylabel,
|
||||
int LabelMap::find_or_create(const std::string &mylabel,
|
||||
std::vector<std::string> &labels, int ntypes)
|
||||
{
|
||||
for (int i = 0; i < ntypes; i++)
|
||||
@ -190,8 +190,10 @@ int LabelMap::find_or_create(std::string mylabel,
|
||||
}
|
||||
|
||||
// if label cannot be found or created, need more space reserved
|
||||
|
||||
error->all(FLERR,"Topology type exceeds system topology type");
|
||||
|
||||
// never reaches here, just to prevent compiler warning
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -199,7 +201,7 @@ int LabelMap::find_or_create(std::string mylabel,
|
||||
return -1 if type not yet defined
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int LabelMap::find(std::string mylabel, int mode)
|
||||
int LabelMap::find(const std::string &mylabel, int mode)
|
||||
{
|
||||
if (mode == Atom::ATOM)
|
||||
return search(mylabel,typelabel,natomtypes);
|
||||
@ -224,8 +226,8 @@ int LabelMap::find(std::string mylabel, int mode)
|
||||
return -1 if type not yet defined
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int LabelMap::search(std::string mylabel,
|
||||
std::vector<std::string> labels, int ntypes)
|
||||
int LabelMap::search(const std::string &mylabel,
|
||||
const std::vector<std::string> &labels, int ntypes)
|
||||
{
|
||||
for (int i = 0; i < ntypes; i++)
|
||||
if (labels[i] == mylabel) return i+1;
|
||||
@ -381,7 +383,7 @@ char *LabelMap::read_string(FILE *fp)
|
||||
byte) into the restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void LabelMap::write_string(std::string str, FILE *fp)
|
||||
void LabelMap::write_string(const std::string &str, FILE *fp)
|
||||
{
|
||||
const char *cstr = str.c_str();
|
||||
int n = strlen(cstr) + 1;
|
||||
|
||||
@ -45,9 +45,9 @@ class LabelMap : protected Pointers {
|
||||
void modify_lmap(int, char **);
|
||||
void merge_lmap(class LabelMap *, int); // copy another lmap into this one
|
||||
void create_lmap2lmap(class LabelMap *, int); // index mapping between two lmaps
|
||||
int find_or_create(std::string, std::vector<std::string> &, int); // look up type or create new type
|
||||
int find(std::string, int); // find numeric type of type label
|
||||
int search(std::string, std::vector<std::string>, int); // look up type index
|
||||
int find_or_create(const std::string &, std::vector<std::string> &, int); // look up type or create new type
|
||||
int find(const std::string &, int); // find numeric type of type label
|
||||
int search(const std::string &, const std::vector<std::string> &, int); // look up type index
|
||||
int is_complete(int); // check if all types are assigned
|
||||
|
||||
// input/output for atom class label map
|
||||
@ -58,7 +58,7 @@ class LabelMap : protected Pointers {
|
||||
|
||||
private:
|
||||
char *read_string(FILE *);
|
||||
void write_string(std::string, FILE *);
|
||||
void write_string(const std::string &, FILE *);
|
||||
int read_int(FILE *);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user