0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

util: Use more compact fmt for abbrev time.

This commit is contained in:
Jason Volk 2018-12-31 15:22:09 -08:00
parent 8f6c17aeb1
commit 3b2188280a

View file

@ -78,6 +78,13 @@ ircd::util::pretty_nanoseconds(const mutable_buffer &out,
{ "days", "d" },
}};
const string_view &fmtstr
{
fmt == 1?
"%.2lf%s"_sv:
"%.2lf %s"_sv
};
auto pos(0);
long double val(ns);
@ -132,9 +139,7 @@ ircd::util::pretty_nanoseconds(const mutable_buffer &out,
done:
return fmt::sprintf
{
out, "%.2lf %s",
val,
unit.at(pos).at(fmt)
out, fmtstr, val, unit.at(pos).at(fmt)
};
}