Skip to content

Commit

Permalink
#374: speed optimization of assignment cycles (avoid copying)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed May 26, 2024
1 parent e71dfd5 commit 5cc7c48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/sbml/validator/constraints/AssignmentCycles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ AssignmentCycles::~AssignmentCycles ()
void
AssignmentCycles::check_ (const Model& m, const Model& object)
{
// this rule ony applies in l2v2 and beyond
// this rule only applies in l2v2 and beyond
if (object.getLevel() == 1
|| (object.getLevel() == 2 && object.getVersion() == 1))
return;
Expand Down Expand Up @@ -271,21 +271,19 @@ AssignmentCycles::determineAllDependencies()


bool
AssignmentCycles::alreadyExistsInMap(IdMap map,
pair<const std::string, std::string> dependency)
AssignmentCycles::alreadyExistsInMap(IdMap& map,
const pair<const std::string, std::string>& dependency) const
{
bool exists = false;

IdIter it;

for (it = map.begin(); it != map.end(); it++)
for (it = map.begin(); it != map.end(); ++it)
{
if (((*it).first == dependency.first)
&& ((*it).second == dependency.second))
exists = true;
return true;
}

return exists;
return false;
}


Expand Down
4 changes: 2 additions & 2 deletions src/sbml/validator/constraints/AssignmentCycles.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class AssignmentCycles: public TConstraint<Model>


/* helper function to check if a pair already exists */
bool alreadyExistsInMap(IdMap map,
std::pair<const std::string, std::string> dependency);
bool alreadyExistsInMap(IdMap& map,
const std::pair<const std::string, std::string>& dependency) const;


/* check for explicit use of original variable */
Expand Down

0 comments on commit 5cc7c48

Please sign in to comment.