From 62f4db4cce2f680256d77e8d54ea646f2ad9d3b8 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 17 Feb 2018 16:10:01 -0800 Subject: [PATCH] ircd::m: Fix/cleanup m::id generator ctor. --- ircd/m/id.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ircd/m/id.cc b/ircd/m/id.cc index 832a651e5..310a4f4d8 100644 --- a/ircd/m/id.cc +++ b/ircd/m/id.cc @@ -457,31 +457,30 @@ ircd::m::id::id(const enum sigil &sigil, { //TODO: output grammar - char name[64]; switch(sigil) + char namebuf[64]; + string_view name; switch(sigil) { case sigil::USER: - printer::random_prefixed("guest", name); + name = printer::random_prefixed("guest", namebuf); break; case sigil::ROOM_ALIAS: - printer::random_prefixed("", name); + name = printer::random_prefixed("", namebuf); break; case sigil::DEVICE: - printer::random_alpha(name, 16); + name = printer::random_alpha(namebuf, 16); break; default: - printer::random_timebased(name); + name = printer::random_timebased(namebuf); break; }; - const auto len + return fmt::sprintf { - fmt::sprintf(buf, "%c%s:%s", char(sigil), name, host) + buf, "%c%s:%s", char(sigil), name, host }; - - return string_view { buffer::data(buf), size_t(len) }; }()} { }