From 425385265afbad22fd228a0403c92a77135477a8 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 27 Apr 2019 16:22:47 -0700 Subject: [PATCH] ircd::m::room::origins: Minor reorg for_each. --- include/ircd/m/room/origins.h | 13 ++++++------- ircd/m_room.cc | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/ircd/m/room/origins.h b/include/ircd/m/room/origins.h index 5b9eb72f4..723125327 100644 --- a/include/ircd/m/room/origins.h +++ b/include/ircd/m/room/origins.h @@ -11,21 +11,20 @@ #pragma once #define HAVE_IRCD_M_ROOM_ORIGINS_H -/// Interface to the origins (autonomous systems) of a room -/// -/// This interface focuses specifically on the origins (from the field in the -/// event object) which are servers/networks/autonomous systems, or something. -/// Messages have to be sent to them, and an efficient iteration of the -/// origins as provided by this interface helps with that. +/// Interface to the servers of a room. Messages have to be sent to them, +/// and an efficient iteration of the origins as provided by this interface +/// helps with that. This includes servers with joined members by default. /// struct ircd::m::room::origins { using closure = std::function; using closure_bool = std::function; + static bool _for_each(const origins &, const closure_bool &view); + m::room room; - bool _for_each_(const closure_bool &view) const; + public: bool for_each(const closure_bool &view) const; void for_each(const closure &view) const; bool has(const string_view &origin) const; diff --git a/ircd/m_room.cc b/ircd/m_room.cc index 494c1c58a..c0a78d538 100644 --- a/ircd/m_room.cc +++ b/ircd/m_room.cc @@ -1761,7 +1761,7 @@ const { size_t ret{0}; const room::origins origins{room}; - origins._for_each_([&ret](const string_view &) + origins._for_each(origins, [&ret](const string_view &) { ++ret; return true; @@ -1916,7 +1916,7 @@ const if(!room.event_id && membership == "join") { const room::origins origins{room}; - return origins._for_each_([&closure, this] + return origins._for_each(origins, [&closure, this] (const string_view &key) { const string_view &member @@ -2078,7 +2078,7 @@ const { string_view last; char lastbuf[rfc1035::NAME_BUF_SIZE]; - return _for_each_([&last, &lastbuf, &view] + return _for_each(*this, [&last, &lastbuf, &view] (const string_view &key) { const string_view &origin @@ -2098,8 +2098,8 @@ const } bool -ircd::m::room::origins::_for_each_(const closure_bool &view) -const +ircd::m::room::origins::_for_each(const origins &origins, + const closure_bool &view) { db::index &index { @@ -2108,7 +2108,7 @@ const auto it { - index.begin(room.room_id) + index.begin(origins.room.room_id) }; for(; bool(it); ++it)