diff --git a/core/indigo-core/molecule/query_molecule.h b/core/indigo-core/molecule/query_molecule.h index 6bf0ff017b..5fc637f9f4 100644 --- a/core/indigo-core/molecule/query_molecule.h +++ b/core/indigo-core/molecule/query_molecule.h @@ -372,7 +372,7 @@ namespace indigo // must belong to different connected components of the target molecule Array components; - std::list>& getComponentNeighbors(); + void getComponentNeighbors(std::list> &componentNeighbors); void invalidateAtom(int index, int mask) override; @@ -399,9 +399,6 @@ namespace indigo PtrArray _atoms; PtrArray _bonds; - - std::list> _component_neighbors; - void _calculateComponentNeighbors(); }; } // namespace indigo diff --git a/core/indigo-core/molecule/src/query_molecule.cpp b/core/indigo-core/molecule/src/query_molecule.cpp index d72007611c..404c892a15 100644 --- a/core/indigo-core/molecule/src/query_molecule.cpp +++ b/core/indigo-core/molecule/src/query_molecule.cpp @@ -2141,7 +2141,7 @@ void QueryMolecule::getQueryAtomLabel(int qa, Array& result) result.readString(it->second.c_str(), true); } -void QueryMolecule::_calculateComponentNeighbors() +void QueryMolecule::getComponentNeighbors(std::list> &componentNeighbors) { std::unordered_map> componentAtoms; for (int i = 0; i < components.size(); ++i) @@ -2152,16 +2152,11 @@ void QueryMolecule::_calculateComponentNeighbors() componentAtoms[componentId].insert(i); } } + componentNeighbors.clear(); for (auto elem : componentAtoms) { auto atoms = elem.second; if (atoms.size() > 1) - _component_neighbors.emplace_back(atoms); + componentNeighbors.emplace_back(atoms); } -} - -std::list>& QueryMolecule::getComponentNeighbors() -{ - _calculateComponentNeighbors(); - return _component_neighbors; } \ No newline at end of file diff --git a/core/indigo-core/reaction/src/rsmiles_loader.cpp b/core/indigo-core/reaction/src/rsmiles_loader.cpp index 8a841271ea..40b695ccaa 100644 --- a/core/indigo-core/reaction/src/rsmiles_loader.cpp +++ b/core/indigo-core/reaction/src/rsmiles_loader.cpp @@ -128,7 +128,7 @@ void RSmilesLoader::_loadReaction() { rcnt = std::make_unique(); r_loader.loadQueryMolecule(static_cast(*rcnt)); - rcnt_extNeibs = static_cast(*rcnt).getComponentNeighbors(); + static_cast(*rcnt).getComponentNeighbors(rcnt_extNeibs); } rcnt_aam.copy(rcnt->reaction_atom_mapping); @@ -162,7 +162,7 @@ void RSmilesLoader::_loadReaction() { ctlt = std::make_unique(); c_loader.loadQueryMolecule(static_cast(*ctlt)); - ctlt_extNeibs = static_cast(*ctlt).getComponentNeighbors(); + static_cast(*ctlt).getComponentNeighbors(ctlt_extNeibs); } ctlt_aam.copy(ctlt->reaction_atom_mapping); @@ -202,7 +202,7 @@ void RSmilesLoader::_loadReaction() { prod = std::make_unique(); p_loader.loadQueryMolecule(static_cast(*prod)); - prod_extNeibs = static_cast(*prod).getComponentNeighbors(); + static_cast(*prod).getComponentNeighbors(prod_extNeibs); } prod_aam.copy(prod->reaction_atom_mapping);