mirror of
https://github.com/matrix-construct/construct
synced 2024-09-29 12:18:54 +02:00
ircd:Ⓜ️:room::messages: Simplify/optimize seek() functions.
This commit is contained in:
parent
d5f01d013d
commit
7e11176ab7
2 changed files with 9 additions and 18 deletions
|
@ -49,9 +49,8 @@ struct ircd::m::room::messages
|
||||||
const m::event &fetch();
|
const m::event &fetch();
|
||||||
|
|
||||||
bool seek_idx(const event::idx &);
|
bool seek_idx(const event::idx &);
|
||||||
bool seek(const uint64_t &depth);
|
bool seek(const uint64_t &depth = -1);
|
||||||
bool seek(const event::id &);
|
bool seek(const event::id &);
|
||||||
bool seek();
|
|
||||||
|
|
||||||
// These are reversed on purpose
|
// These are reversed on purpose
|
||||||
auto &operator++() { return --it; }
|
auto &operator++() { return --it; }
|
||||||
|
|
|
@ -683,36 +683,28 @@ ircd::m::room::messages::operator*()
|
||||||
return fetch(std::nothrow);
|
return fetch(std::nothrow);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
|
||||||
ircd::m::room::messages::seek()
|
|
||||||
{
|
|
||||||
this->it = dbs::room_events.begin(room.room_id);
|
|
||||||
return bool(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::m::room::messages::seek(const event::id &event_id)
|
ircd::m::room::messages::seek(const event::id &event_id)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
const event::idx &event_idx
|
const event::idx &event_idx
|
||||||
{
|
{
|
||||||
index(event_id)
|
index(event_id, std::nothrow)
|
||||||
};
|
};
|
||||||
|
|
||||||
return seek_idx(event_idx);
|
return event_idx?
|
||||||
}
|
seek_idx(event_idx):
|
||||||
catch(const db::not_found &e)
|
false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::m::room::messages::seek(const uint64_t &depth)
|
ircd::m::room::messages::seek(const uint64_t &depth)
|
||||||
{
|
{
|
||||||
char buf[dbs::ROOM_EVENTS_KEY_MAX_SIZE];
|
char buf[dbs::ROOM_EVENTS_KEY_MAX_SIZE];
|
||||||
const auto seek_key
|
const string_view seek_key
|
||||||
{
|
{
|
||||||
dbs::room_events_key(buf, room.room_id, depth)
|
depth != uint64_t(-1)?
|
||||||
|
dbs::room_events_key(buf, room.room_id, depth):
|
||||||
|
room.room_id
|
||||||
};
|
};
|
||||||
|
|
||||||
this->it = dbs::room_events.begin(seek_key);
|
this->it = dbs::room_events.begin(seek_key);
|
||||||
|
|
Loading…
Reference in a new issue