From c258811d7674205e331786da7a8b26bb76670098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Wed, 1 Feb 2023 14:50:10 +0100 Subject: [PATCH] Turn 'm_var_invmap' into a much simpler (and faster) vector --- src/qbf.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qbf.cpp b/src/qbf.cpp index f41e4cc9..7cf6a149 100644 --- a/src/qbf.cpp +++ b/src/qbf.cpp @@ -417,7 +417,7 @@ class qcir /// \details If you want to find the Cleansed Input Variable from its name, /// just use `m_gvar_map` to find the gate and its `var` member. ////////////////////////////////////////////////////////////////////////////// - std::unordered_map m_var_invmap; + std::vector m_var_invmap; ////////////////////////////////////////////////////////////////////////////// /// \brief List of gates. @@ -834,7 +834,7 @@ class qcir if (vars() <= static_cast(std::abs(i))) { throw std::out_of_range("Given 'i' is an unknown variable"); } - return (i < 0 ? "-" : "") + (*m_var_invmap.find(std::abs(i))).second; + return (i < 0 ? "-" : "") + m_var_invmap.at(std::abs(i)); } ////////////////////////////////////////////////////////////////////////////// @@ -907,7 +907,7 @@ class qcir } const int cvar = m_vars++; - m_var_invmap.insert({ cvar, var }); + m_var_invmap.push_back(var); return (negated ? -1 : 1) * __push_gate(unnegated_var, 0u, var_gate(cvar)); }