From f9fd03b9589c5c299e2c360f464975d3f237f5a2 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Mon, 26 Mar 2018 20:41:16 +0300 Subject: [PATCH] Simplify variant usage --- src/Cache.cc | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/Cache.cc b/src/Cache.cc index 8a58b634..3c8a1bb3 100644 --- a/src/Cache.cc +++ b/src/Cache.cc @@ -22,6 +22,8 @@ #include #include +#include + #include "Cache.h" #include "RoomState.h" @@ -420,12 +422,6 @@ Cache::setInvites(const std::map &invi if (!isMounted_) return; - using Aliases = mtx::events::StrippedEvent; - using Avatar = mtx::events::StrippedEvent; - using Member = mtx::events::StrippedEvent; - using Name = mtx::events::StrippedEvent; - using Topic = mtx::events::StrippedEvent; - try { auto txn = lmdb::txn::begin(env_); @@ -433,20 +429,9 @@ Cache::setInvites(const std::map &invi nlohmann::json j; for (const auto &e : it->second.invite_state) { - if (mpark::holds_alternative(e)) { - j["invite_state"]["events"].push_back(mpark::get(e)); - } else if (mpark::holds_alternative(e)) { - j["invite_state"]["events"].push_back(mpark::get(e)); - } else if (mpark::holds_alternative(e)) { - j["invite_state"]["events"].push_back( - mpark::get(e)); - } else if (mpark::holds_alternative(e)) { - j["invite_state"]["events"].push_back( - mpark::get(e)); - } else if (mpark::holds_alternative(e)) { - j["invite_state"]["events"].push_back( - mpark::get(e)); - } + mpark::visit( + [&j](auto msg) { j["invite_state"]["events"].push_back(msg); }, + e); } lmdb::dbi_put(txn, invitesDb_, lmdb::val(it->first), lmdb::val(j.dump()));