From 9981cf4ce9ab90d4a0b42e16dc746701d9b85320 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 8 Aug 2017 13:35:56 +0200 Subject: [PATCH] Make some AVL tree code less verbose. --- src/lol/base/avl_tree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lol/base/avl_tree.h b/src/lol/base/avl_tree.h index deb80651..a921dd64 100644 --- a/src/lol/base/avl_tree.h +++ b/src/lol/base/avl_tree.h @@ -341,8 +341,8 @@ protected: void update_balance() { - m_stairs[0] = m_child[0] ? (m_child[0]->m_stairs[0] > m_child[0]->m_stairs[1] ? m_child[0]->m_stairs[0] : m_child[0]->m_stairs[1]) + 1 : 0; - m_stairs[1] = m_child[1] ? (m_child[1]->m_stairs[0] > m_child[1]->m_stairs[1] ? m_child[1]->m_stairs[0] : m_child[1]->m_stairs[1]) + 1 : 0; + for (int i = 0; i <= 1; ++i) + m_stairs[i] = m_child[i] ? std::max(m_child[i]->m_stairs[0], m_child[i]->m_stairs[1]) + 1 : 0; } void rebalance_if_needed()