From 13830061a3dc26619a621bb4c7d16ea57807eb57 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 16 Jul 2019 10:22:49 -0700 Subject: [PATCH] ircd::m::event::refs: Add overload to check if ref type exists. --- include/ircd/m/event/refs.h | 1 + ircd/m_event.cc | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/ircd/m/event/refs.h b/include/ircd/m/event/refs.h index e6be9e649..fba0f6694 100644 --- a/include/ircd/m/event/refs.h +++ b/include/ircd/m/event/refs.h @@ -33,6 +33,7 @@ struct ircd::m::event::refs bool has(const dbs::ref &type, const event::idx &) const noexcept; bool has(const event::idx &) const noexcept; + bool has(const dbs::ref &) const noexcept; size_t count(const dbs::ref &type) const noexcept; size_t count() const noexcept; diff --git a/ircd/m_event.cc b/ircd/m_event.cc index 17808be34..92db91c59 100644 --- a/ircd/m_event.cc +++ b/ircd/m_event.cc @@ -2815,7 +2815,7 @@ const noexcept assert(idx); size_t ret(0); for_each(type, [&ret] - (const event::idx &ref, const dbs::ref &) + (const event::idx &, const dbs::ref &) { ++ret; return true; @@ -2824,6 +2824,18 @@ const noexcept return ret; } +bool +ircd::m::event::refs::has(const dbs::ref &type) +const noexcept +{ + return !for_each(type, [&type] + (const event::idx &, const dbs::ref &ref) + { + assert(ref == type); + return false; + }); +} + bool ircd::m::event::refs::has(const event::idx &idx) const noexcept