From b5df21f9c5b59a99c264a7a61a19d94c400c0099 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 13 Apr 2023 23:26:12 +0200 Subject: [PATCH] Simplify function: for LCA both iterators shall be in the same tree --- m-tree.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/m-tree.h b/m-tree.h index aa7de850..cdd3d421 100644 --- a/m-tree.h +++ b/m-tree.h @@ -942,6 +942,7 @@ typedef int32_t m_tr33_index_t; M_C(name, _lca)(it_t it1, it_t it2) { \ M_TR33_IT_CONTRACT(it1, true); \ M_TR33_IT_CONTRACT(it2, true); \ + M_ASSERT(it1.tree == it2.tree); \ /* Compute the Lowest Common Ancestor in linear time */ \ int32_t d1 = M_C(name, _depth)(it1); \ int32_t d2 = M_C(name, _depth)(it2); \ @@ -961,10 +962,8 @@ typedef int32_t m_tr33_index_t; b = M_C(name, _it_up)(&it1); \ b = M_C(name, _it_up)(&it2); \ } \ - /* If we went back to the root node, and cannot find a common node */ \ - if (b == false) { \ - it1.index = M_TR33_NO_NODE; \ - } \ + /* If we went back to the root node, we must have found a common node*/ \ + M_ASSERT(b); \ return it1; \ } \ \