diff --git a/ircd/m/v1.cc b/ircd/m/v1.cc index 46b879ba0..9a9bd8724 100644 --- a/ircd/m/v1.cc +++ b/ircd/m/v1.cc @@ -48,19 +48,14 @@ ircd::m::v1::groups::publicised::publicised(const id::node &node, }); // (front of buf was advanced by stringify) - opts.out.head = opts.request(buf); opts.out.content = json::get<"content"_>(opts.request); + opts.out.head = opts.request(buf); if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = opts.in.head; + consume(buf, size(opts.out.head)); + opts.in.head = buf; + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -128,14 +123,8 @@ ircd::m::v1::send::send(const string_view &txnid, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = opts.in.head; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -207,14 +196,8 @@ ircd::m::v1::backfill::backfill(const room::id &room_id, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = mutable_buffer{}; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -286,14 +269,8 @@ ircd::m::v1::state::state(const room::id &room_id, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = mutable_buffer{}; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -353,14 +330,8 @@ ircd::m::v1::event::event(const m::event::id &event_id, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = opts.in.head; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -413,14 +384,8 @@ ircd::m::v1::invite::invite(const room::id &room_id, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = mutable_buffer{}; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -473,14 +438,8 @@ ircd::m::v1::send_join::send_join(const room::id &room_id, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = mutable_buffer{}; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -543,14 +502,8 @@ ircd::m::v1::make_join::make_join(const room::id &room_id, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = opts.in.head; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -600,14 +553,8 @@ ircd::m::v1::user::devices::devices(const id::user &user_id, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = opts.in.head; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -814,14 +761,8 @@ ircd::m::v1::query::query(const string_view &type, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = opts.in.head; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request @@ -857,14 +798,8 @@ ircd::m::v1::version::version(const mutable_buffer &buf, if(!size(opts.in)) { - const auto in_max - { - std::max(ssize_t(size(buf) - size(opts.out.head)), ssize_t(0)) - }; - - assert(in_max >= ssize_t(size(buf) / 2)); - opts.in.head = { data(buf) + size(opts.out.head), size_t(in_max) }; - opts.in.content = opts.in.head; + opts.in.head = buf + size(opts.out.head); + opts.in.content = opts.in.head; // server::request will auto partition } return server::request