@@ -55,6 +55,7 @@ auto Callbacks::make_uci_printer(
5555
5656namespace {
5757 using std::string;
58+ using std::string_view;
5859
5960 enum class Alignment : std::uint_least8_t {
6061 Left,
@@ -66,7 +67,7 @@ namespace {
6667
6768 template <Alignment Align>
6869 [[nodiscard]] auto get_column_text (
69- const std:: string_view text) -> string
70+ const string_view text) -> string
7071 {
7172 assert (text.size () < COLUMN_WIDTH);
7273
@@ -89,11 +90,14 @@ namespace {
8990
9091 template <Alignment Align>
9192 void print_column_text (
92- const std:: string_view text)
93+ const string_view text)
9394 {
9495 std::cout << get_column_text<Align>(text);
9596 }
9697
98+ inline constexpr string_view FRACTIONAL_DURATION_FMT { " {:.2%Q %q}" };
99+ inline constexpr string_view INTEGER_DURATION_FMT { " {:%Q %q}" };
100+
97101 template <util::ChronoDuration Duration>
98102 [[nodiscard]] auto get_duration_string (
99103 const milliseconds duration) -> std::optional<string>
@@ -104,7 +108,7 @@ namespace {
104108 using FractionalDuration = util::FractionalDuration<Duration>;
105109
106110 return std::format (
107- " {:.2%Q %q} " ,
111+ FRACTIONAL_DURATION_FMT ,
108112 duration_cast<FractionalDuration>(duration));
109113 }
110114
@@ -118,7 +122,9 @@ namespace {
118122 return get_duration_string<std::chrono::hours>(duration)
119123 .or_else ([duration] { return get_duration_string<std::chrono::minutes>(duration); })
120124 .or_else ([duration] { return get_duration_string<std::chrono::seconds>(duration); })
121- .or_else ([duration] { return std::make_optional (std::format (" {:%Q %q}" , duration)); })
125+ .or_else ([duration] {
126+ return std::make_optional (std::format (INTEGER_DURATION_FMT, duration));
127+ })
122128 .value ();
123129 }
124130
@@ -241,12 +247,8 @@ namespace {
241247
242248 string result;
243249
244- for (const auto move : pv) {
245- result.append (printMove (move));
246- result.append (1uz, ' ' );
247- }
248-
249- result.pop_back (); // trim last space
250+ for (const auto move : pv)
251+ result.append (std::format (" {} " , printMove (move)));
250252
251253 return result;
252254 }
0 commit comments