From 1b9e306ff00e55f7ce00b5bc55498370b65c5e02 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 16 Jan 2019 17:53:47 -0800 Subject: [PATCH] ircd::m::event::fetch: Various fixes / minor reorg. --- include/ircd/m/event/fetch.h | 2 +- ircd/m/event.cc | 34 ++++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/include/ircd/m/event/fetch.h b/include/ircd/m/event/fetch.h index 32590a59f..013a1238a 100644 --- a/include/ircd/m/event/fetch.h +++ b/include/ircd/m/event/fetch.h @@ -52,7 +52,7 @@ struct ircd::m::event::fetch fetch(const opts & = default_opts); fetch(fetch &&) = delete; fetch(const fetch &) = delete; - fetch &operator=(fetch &&) = default; + fetch &operator=(fetch &&) = delete; fetch &operator=(const fetch &) = delete; static bool event_id(const idx &, std::nothrow_t, const id::closure &); diff --git a/ircd/m/event.cc b/ircd/m/event.cc index 1f3dc521a..d2ac44dfe 100644 --- a/ircd/m/event.cc +++ b/ircd/m/event.cc @@ -1210,14 +1210,6 @@ const }; } -// -// event::fetch -// - -decltype(ircd::m::event::fetch::default_opts) -ircd::m::event::fetch::default_opts -{}; - void ircd::m::prefetch(const event::id &event_id, const event::fetch::opts &opts) @@ -1554,9 +1546,13 @@ ircd::m::seek(event::fetch &fetch, fetch._json.val() }; + event = + { + source, opts.keys + }; + + assert(data(event.source) == data(source)); assert(fetch.valid); - assert(!empty(source)); - event = m::event{source, opts.keys}; return fetch.valid; } @@ -1576,6 +1572,14 @@ ircd::m::seek(event::fetch &fetch, return fetch.valid; } +// +// event::fetch +// + +decltype(ircd::m::event::fetch::default_opts) +ircd::m::event::fetch::default_opts +{}; + void ircd::m::event::fetch::event_id(const idx &idx, const id::closure &closure) @@ -1595,9 +1599,14 @@ ircd::m::event::fetch::event_id(const idx &idx, return get(std::nothrow, idx, "event_id", closure); } +// +// event::fetch::fetch +// + /// Seekless constructor. ircd::m::event::fetch::fetch(const opts &opts) -:_json +:event{} +,_json { m::dbs::event_json, string_view{}, @@ -1668,7 +1677,8 @@ ircd::m::event::fetch::fetch(const event::idx &event_idx, } { if(likely(event_idx)) - seek(*this, event_idx, std::nothrow, opts); + if(!seek(*this, event_idx, std::nothrow, opts)) + assert(!valid); } //