0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01:00

ircd: Applications of loopless copy overload for single character.

This commit is contained in:
Jason Volk 2020-04-13 22:46:11 -07:00
parent 0196ec46f9
commit cb41660c94
16 changed files with 47 additions and 47 deletions

View file

@ -90,17 +90,17 @@ stringify(mutable_buffer &buf,
const tuple<T...> *e)
{
const auto start(begin(buf));
consume(buf, copy(buf, "["_sv));
consume(buf, copy(buf, '['));
if(b != e)
{
stringify(buf, *b);
for(++b; b != e; ++b)
{
consume(buf, copy(buf, ","_sv));
consume(buf, copy(buf, ','));
stringify(buf, *b);
}
}
consume(buf, copy(buf, "]"_sv));
consume(buf, copy(buf, ']'));
return { start, begin(buf) };
}

View file

@ -379,7 +379,7 @@ try
// Ensure null termination if out buffer is non-empty.
assert(size(this->out) > 0);
assert(this->out.remaining());
copy(this->out, "\0"_sv);
copy(this->out, '\0');
}
catch(const std::out_of_range &e)
{

View file

@ -2734,7 +2734,7 @@ ircd::json::stringify(mutable_buffer &buf,
{
char *const start(begin(buf));
assert(!surrounds(member.first, '"'));
consume(buf, copy(buf, "\""_sv));
consume(buf, copy(buf, '"'));
consume(buf, copy(buf, member.first));
consume(buf, copy(buf, "\":"_sv));
stringify(buf, member.second);

View file

@ -2577,17 +2577,17 @@ ircd::net::string(const mutable_buffer &buf,
};
if(need_bracket)
consume(out, copy(out, "["_sv));
consume(out, copy(out, '['));
if(ipp)
consume(out, size(string(out, std::get<ipport::IP>(ipp))));
if(need_bracket)
consume(out, copy(out, "]"_sv));
consume(out, copy(out, ']'));
if(has_port)
{
consume(out, copy(out, ":"_sv));
consume(out, copy(out, ':'));
consume(out, size(lex_cast(port(ipp), out)));
}

View file

@ -581,7 +581,7 @@ ircd::rfc3986::encode(const mutable_buffer &out,
};
consume(buf, size(encode(buf, member.first)));
consume(buf, copy(buf, "="_sv));
consume(buf, copy(buf, '='));
consume(buf, size(encode(buf, member.second)));
}};
@ -591,7 +591,7 @@ ircd::rfc3986::encode(const mutable_buffer &out,
append(*it);
for(++it; it != end(members); ++it)
{
consume(buf, copy(buf, "&"_sv));
consume(buf, copy(buf, '&'));
append(*it);
}
}

View file

@ -297,7 +297,7 @@ ircd::m::dbs::event_horizon_key(const mutable_buffer &out,
if(event_idx)
{
consume(buf, copy(buf, "\0"_sv));
consume(buf, copy(buf, '\0'));
consume(buf, copy(buf, byte_view<string_view>(event_idx)));
}

View file

@ -226,7 +226,7 @@ ircd::m::dbs::event_sender_key(const mutable_buffer &out_,
if(user_id && event_idx)
{
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, byte_view<string_view>(event_idx)));
}
@ -283,7 +283,7 @@ ircd::m::dbs::event_sender_origin_key(const mutable_buffer &out_,
if(localpart && event_idx)
{
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, byte_view<string_view>(event_idx)));
}

View file

@ -204,17 +204,17 @@ ircd::m::dbs::event_state_key(const string_view &amalgam)
assert(!startswith(amalgam, '\0'));
const auto &[state_key, r0]
{
split(amalgam, "\0"_sv)
split(amalgam, '\0')
};
const auto &[type, r1]
{
split(r0, "\0"_sv)
split(r0, '\0')
};
const auto &[room_id, r2]
{
split(r1, "\0"_sv)
split(r1, '\0')
};
assert(!room_id || m::valid(m::id::ROOM, room_id));
@ -252,20 +252,20 @@ ircd::m::dbs::event_state_key(const mutable_buffer &out_,
if(!type)
return {data(out_), data(out)};
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
if(!room_id)
return {data(out_), data(out)};
assert(m::valid(m::id::ROOM, room_id));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, room_id));
if(depth < 0)
return {data(out_), data(out)};
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, byte_view<string_view>(depth)));
if(!event_idx)

View file

@ -185,7 +185,7 @@ ircd::m::dbs::event_type_key(const mutable_buffer &out_,
mutable_buffer out{out_};
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, byte_view<string_view>(event_idx)));
return { data(out_), data(out) };
}

View file

@ -73,7 +73,7 @@ ircd::m::dbs::desc::room_events__pfx
[](const string_view &key)
{
return split(key, "\0"_sv).first;
return split(key, '\0').first;
}
};
@ -292,7 +292,7 @@ ircd::m::dbs::room_events_key(const mutable_buffer &out_,
mutable_buffer out{out_};
consume(out, copy(out, room_id));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, depth_cb));
return { data(out_), data(out) };
}
@ -315,7 +315,7 @@ ircd::m::dbs::room_events_key(const mutable_buffer &out_,
mutable_buffer out{out_};
consume(out, copy(out, room_id));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, depth_cb));
consume(out, copy(out, event_idx_cb));
return { data(out_), data(out) };

View file

@ -52,7 +52,7 @@ ircd::m::dbs::desc::room_head__pfx
[](const string_view &key)
{
return split(key, "\0"_sv).first;
return split(key, '\0').first;
}
};
@ -207,7 +207,7 @@ ircd::m::dbs::room_head_key(const string_view &amalgam)
{
const auto &key
{
lstrip(amalgam, "\0"_sv)
lstrip(amalgam, '\0')
};
return
@ -223,7 +223,7 @@ ircd::m::dbs::room_head_key(const mutable_buffer &out_,
{
mutable_buffer out{out_};
consume(out, copy(out, room_id));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, event_id));
return { data(out_), data(out) };
}

View file

@ -72,7 +72,7 @@ ircd::m::dbs::desc::room_joined__pfx
[](const string_view &key)
{
return split(key, "\0"_sv).first;
return split(key, '\0').first;
}
};
@ -200,12 +200,12 @@ ircd::m::dbs::room_joined_key(const string_view &amalgam)
{
const auto &key
{
lstrip(amalgam, "\0"_sv)
lstrip(amalgam, '\0')
};
const auto &s
{
split(key, "@"_sv)
split(key, '@')
};
return
@ -224,7 +224,7 @@ ircd::m::dbs::room_joined_key(const mutable_buffer &out_,
{
mutable_buffer out{out_};
consume(out, copy(out, room_id));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, origin));
return { data(out_), data(out) };
}
@ -237,7 +237,7 @@ ircd::m::dbs::room_joined_key(const mutable_buffer &out_,
{
mutable_buffer out{out_};
consume(out, copy(out, room_id));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, origin));
consume(out, copy(out, member));
return { data(out_), data(out) };

View file

@ -76,7 +76,7 @@ ircd::m::dbs::desc::room_state__pfx
[](const string_view &key)
{
return split(key, "\0"_sv).first;
return split(key, '\0').first;
}
};
@ -201,13 +201,13 @@ ircd::m::dbs::room_state_key(const mutable_buffer &out_,
if(likely(defined(type)))
{
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
}
if(defined(state_key))
{
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, trunc(state_key, event::STATE_KEY_MAX_SIZE)));
}
@ -219,12 +219,12 @@ ircd::m::dbs::room_state_key(const string_view &amalgam)
{
const auto &key
{
lstrip(amalgam, "\0"_sv)
lstrip(amalgam, '\0')
};
const auto &s
{
split(key, "\0"_sv)
split(key, '\0')
};
return

View file

@ -83,7 +83,7 @@ ircd::m::dbs::desc::room_state_space__pfx
[](const string_view &key)
{
return split(key, "\0"_sv).first;
return split(key, '\0').first;
}
};
@ -258,17 +258,17 @@ ircd::m::dbs::room_state_space_key(const string_view &amalgam)
{
const auto &key
{
lstrip(amalgam, "\0"_sv)
lstrip(amalgam, '\0')
};
const auto &[type, after_type]
{
split(key, "\0"_sv)
split(key, '\0')
};
const auto &[state_key, after_state_key]
{
split(after_type, "\0"_sv)
split(after_type, '\0')
};
const int64_t &depth
@ -325,11 +325,11 @@ ircd::m::dbs::room_state_space_key(const mutable_buffer &out_,
{
mutable_buffer out{out_};
consume(out, copy(out, room_id));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, trunc(state_key, event::STATE_KEY_MAX_SIZE)));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, byte_view<string_view>(depth)));
consume(out, copy(out, byte_view<string_view>(event_idx)));
return { data(out_), data(out) };

View file

@ -72,7 +72,7 @@ ircd::m::dbs::desc::room_type__pfx
[](const string_view &key)
{
return split(key, "\0"_sv).first;
return split(key, '\0').first;
}
};
@ -305,9 +305,9 @@ ircd::m::dbs::room_type_key(const mutable_buffer &out_,
if(!type)
return { data(out_), data(out) };
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
consume(out, copy(out, "\0"_sv));
consume(out, copy(out, '\0'));
consume(out, copy(out, byte_view<string_view>(depth)));
consume(out, copy(out, byte_view<string_view>(event_idx)));
return { data(out_), data(out) };

View file

@ -389,7 +389,7 @@ const
continue;
if(begin(buf) != begin(out))
consume(buf, copy(buf, " "_sv));
consume(buf, copy(buf, ' '));
consume(buf, copy(buf, m::reflect(code(i))));
}