diff --git a/otc/taxonomy/patching.cpp b/otc/taxonomy/patching.cpp index b8a3d7a2..67727f1d 100644 --- a/otc/taxonomy/patching.cpp +++ b/otc/taxonomy/patching.cpp @@ -290,7 +290,16 @@ bool_str_t PatchableTaxonomy::add_new_taxon(OttId oid, auto & tree = this->get_mutable_tax_tree(); auto & rt_data = tree.get_data(); - // 1. Check if the new taxon is a homonym of an existing taxon. + // 1. Check if the OTT ID is already used. + auto itnit = included_taxon_from_id(oid); + auto itrit = rt_data.id_to_record.find(oid); + if (itnit != nullptr || itrit != rt_data.id_to_record.end()) { + std::string expl = "OTT ID " + std::to_string(oid); + expl += " is already used."; + return bool_str_t{false, expl}; + } + + // 2. Check if the new taxon is a homonym of an existing taxon. auto nm_nd_it = rt_data.name_to_node.find(name); if (nm_nd_it == rt_data.name_to_node.end()) { if (homonym_of != nullptr) { @@ -302,15 +311,6 @@ bool_str_t PatchableTaxonomy::add_new_taxon(OttId oid, return bool_str_t{false, expl}; } - // 2. Check if the OTT ID is already used. - auto itnit = included_taxon_from_id(oid); - auto itrit = rt_data.id_to_record.find(oid); - if (itnit != nullptr || itrit != rt_data.id_to_record.end()) { - std::string expl = "OTT ID " + std::to_string(oid); - expl += " is already used."; - return bool_str_t{false, expl}; - } - // 3. Find the parent taxon by its OTT ID. RTRichTaxNode * par_ptr = const_cast(included_taxon_from_id(parent_id)); if (par_ptr == nullptr) {