Unverified Commit df29364b authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

simplify find/delete fix/compute functions in modify.cpp

parent f670464a
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
@@ -1031,7 +1031,7 @@ void Modify::modify_fix(int narg, char **arg)
   Atom class must update indices in its list of callbacks to fixes
------------------------------------------------------------------------- */

void Modify::delete_fix(const char *id)
void Modify::delete_fix(const std::string &id)
{
  int ifix = find_fix(id);
  if (ifix < 0) error->all(FLERR,"Could not find fix ID to delete");
@@ -1055,14 +1055,12 @@ void Modify::delete_fix(int ifix)
   return index of fix or -1 if not found
------------------------------------------------------------------------- */

int Modify::find_fix(const char *id)
int Modify::find_fix(const std::string &id)
{
  if (id == NULL) return -1;
  int ifix;
  for (ifix = 0; ifix < nfix; ifix++)
    if (strcmp(id,fix[ifix]->id) == 0) break;
  if (ifix == nfix) return -1;
  return ifix;
  if (id.empty()) return -1;
  for (int ifix = 0; ifix < nfix; ifix++)
    if (id == fix[ifix]->id) return ifix;
  return -1;
}

/* ----------------------------------------------------------------------
@@ -1295,7 +1293,7 @@ void Modify::modify_compute(int narg, char **arg)
   delete a Compute from list of Computes
------------------------------------------------------------------------- */

void Modify::delete_compute(const char *id)
void Modify::delete_compute(const std::string &id)
{
  int icompute = find_compute(id);
  if (icompute < 0) error->all(FLERR,"Could not find compute ID to delete");
@@ -1312,14 +1310,12 @@ void Modify::delete_compute(const char *id)
   return index of compute or -1 if not found
------------------------------------------------------------------------- */

int Modify::find_compute(const char *id)
int Modify::find_compute(const std::string &id)
{
  if(id==NULL) return -1;
  int icompute;
  for (icompute = 0; icompute < ncompute; icompute++)
    if (strcmp(id,compute[icompute]->id) == 0) break;
  if (icompute == ncompute) return -1;
  return icompute;
  if(id.empty()) return -1;
  for (int icompute = 0; icompute < ncompute; icompute++)
    if (id == compute[icompute]->id) return icompute;
  return -1;
}

/* ----------------------------------------------------------------------
+4 −4
Original line number Diff line number Diff line
@@ -99,9 +99,9 @@ class Modify : protected Pointers {
  void add_fix(const std::string &, int trysuffix=1);
  void replace_fix(const char *, int, char **, int trysuffix=1);
  void modify_fix(int, char **);
  void delete_fix(const char *);
  void delete_fix(const std::string &);
  void delete_fix(int);
  int find_fix(const char *);
  int find_fix(const std::string &);
  int find_fix_by_style(const char *);
  int check_package(const char *);
  int check_rigid_group_overlap(int);
@@ -111,8 +111,8 @@ class Modify : protected Pointers {
  void add_compute(int, char **, int trysuffix=1);
  void add_compute(const std::string &, int trysuffix=1);
  void modify_compute(int, char **);
  void delete_compute(const char *);
  int find_compute(const char *);
  void delete_compute(const std::string &);
  int find_compute(const std::string &);

  void clearstep_compute();
  void addstep_compute(bigint);