simplify by returning new variable index in creator function and avoid calling finder

This commit is contained in:
Axel Kohlmeyer
2025-06-13 04:37:09 -04:00
parent c5920eeb8d
commit 3a628ce4b1
8 changed files with 27 additions and 54 deletions

View File

@ -1316,7 +1316,7 @@ void Variable::internal_set(int ivar, double value)
create an INTERNAL style variable with name, set to value
------------------------------------------------------------------------- */
void Variable::internal_create(char *name, double value)
int Variable::internal_create(char *name, double value)
{
if (find(name) >= 0)
error->all(FLERR,"Creation of internal-style variable {} which already exists", name);
@ -1334,6 +1334,7 @@ void Variable::internal_create(char *name, double value)
error->all(FLERR, "Variable name '{}' must have only letters, numbers, or underscores", name);
names[nvar] = utils::strdup(name);
nvar++;
return nvar - 1;
}
/* ----------------------------------------------------------------------