Skip to content

Commit 1b3a5ab

Browse files
committed
[tidy] use FMT_STRING()/fmt::to_string() where possible
1 parent 07f577b commit 1b3a5ab

6 files changed

Lines changed: 16 additions & 22 deletions

File tree

src/base/humanize.network.tests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ TEST_CASE("humanize::network::path")
7272
CHECK(!rp.p_locality.l_service.has_value());
7373
CHECK(rp.p_path == "/var/log");
7474

75-
CHECK(fmt::format(FMT_STRING("{}"), rp.p_locality)
75+
CHECK(fmt::to_string(rp.p_locality)
7676
== "dean@[fe80::184f:c67:baf1:fe02%en0]");
7777
}
7878

@@ -88,7 +88,7 @@ TEST_CASE("humanize::network::path")
8888
CHECK(!rp.p_locality.l_service.has_value());
8989
CHECK(rp.p_path == "/var/log");
9090

91-
CHECK(fmt::format("{}", rp.p_locality)
91+
CHECK(fmt::to_string(rp.p_locality)
9292
== "[fe80::184f:c67:baf1:fe02%en0]");
9393
}
9494

src/files_sub_source.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ files_overlay_source::list_static_overlay(const listview_curses& lv,
445445
const auto& prog = sp->sp_extractions.front();
446446

447447
value_out.with_ansi_string(fmt::format(
448-
"{} Extracting " ANSI_COLOR(COLOR_CYAN) "{}" ANSI_NORM
449-
"... {:>8}/{}",
448+
FMT_STRING("{} Extracting " ANSI_COLOR(COLOR_CYAN) "{}" ANSI_NORM
449+
"... {:>8}/{}"),
450450
humanize::sparkline(prog.ep_out_size, prog.ep_total_size),
451451
prog.ep_path.filename().string(),
452452
humanize::file_size(prog.ep_out_size, humanize::alignment::none),
@@ -458,7 +458,8 @@ files_overlay_source::list_static_overlay(const listview_curses& lv,
458458
auto first_iter = sp->sp_tailers.begin();
459459

460460
value_out.with_ansi_string(fmt::format(
461-
"{} Connecting to " ANSI_COLOR(COLOR_CYAN) "{}" ANSI_NORM ": {}",
461+
FMT_STRING("{} Connecting to " ANSI_COLOR(COLOR_CYAN) "{}" ANSI_NORM
462+
": {}"),
462463
PROG[spinner_index() % PROG_SIZE],
463464
first_iter->first,
464465
first_iter->second.tp_message));

src/lnav.prompt.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,8 @@ prompt::refresh_sql_completions(textview_curses& tc)
391391
this->insert_sql_completion(
392392
name, sql_function_t{func->ht_parameters.size()});
393393
if (!func->ht_prql_path.empty()) {
394-
auto prql_name
395-
= fmt::format(FMT_STRING("{}"),
396-
fmt::join(func->ht_prql_path, "."));
394+
auto prql_name = fmt::to_string(
395+
fmt::join(func->ht_prql_path, "."));
397396
this->insert_sql_completion(prql_name,
398397
prql_function_t{});
399398
}
@@ -1008,8 +1007,7 @@ prompt::get_cmd_parameter_completion(textview_curses& tc,
10081007
&& rp_opt)
10091008
{
10101009
auto rp_path = rp_opt.value();
1011-
auto remote_prefix
1012-
= fmt::format(FMT_STRING("{}"), rp_path.p_locality);
1010+
auto remote_prefix = fmt::to_string(rp_path.p_locality);
10131011

10141012
log_info("completing remote path: %s -- %s",
10151013
remote_prefix.c_str(),

src/log_format.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,8 +2951,8 @@ rewrite_json_field(yajlpp_parse_context* ypc,
29512951
{
29522952
jlu->jlu_format->lf_date_time.relock(ls);
29532953
jlu->jlu_scan_error = log_format::scan_error{
2954-
fmt::format("failed to parse timestamp '{}' in string "
2955-
"property '{}'",
2954+
fmt::format(FMT_STRING("failed to parse timestamp "
2955+
"'{}' in string property '{}'"),
29562956
frag,
29572957
field_name)};
29582958
}

src/plain_text_source.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include "plain_text_source.hh"
3131

3232
#include "base/intern_string.hh"
33-
#include "base/string_util.hh"
3433
#include "base/itertools.hh"
34+
#include "base/string_util.hh"
3535
#include "config.h"
3636
#include "document.sections.hh"
3737
#include "scn/scan.h"
@@ -178,12 +178,8 @@ plain_text_source::text_value_for_line(textview_curses& tc,
178178
value_out = this->tds_lines[row].tl_value.get_string();
179179
this->tds_line_indent_size = compute_indent_size(value_out);
180180
if (this->tds_line_indent_size == 0 && value_out.empty()) {
181-
for (auto next = row + 1;
182-
next < (int) this->tds_lines.size();
183-
++next)
184-
{
185-
const auto& next_str
186-
= this->tds_lines[next].tl_value.get_string();
181+
for (auto next = row + 1; next < (int) this->tds_lines.size(); ++next) {
182+
const auto& next_str = this->tds_lines[next].tl_value.get_string();
187183
this->tds_line_indent_size = compute_indent_size(next_str) + 1;
188184
if (!next_str.empty()) {
189185
break;
@@ -517,7 +513,7 @@ plain_text_source::adjacent_anchor(vis_line_t vl, direction dir)
517513
tl.tl_offset, tl.tl_offset + tl.tl_value.al_string.length());
518514

519515
log_trace("adjacent_anchor: curr path = %s",
520-
fmt::format(FMT_STRING("{}"), path_for_line).c_str());
516+
fmt::to_string(path_for_line).c_str());
521517
const auto& md = this->tds_doc_sections;
522518
if (path_for_line.empty()) {
523519
auto neighbors_res = md.m_sections_root->line_neighbors(vl);

src/sqlite-extension-func.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ struct prql_hier {
100100
static void
101101
register_help(prql_hier& phier, const help_text& ht)
102102
{
103-
auto prql_fqid
104-
= fmt::format(FMT_STRING("{}"), fmt::join(ht.ht_prql_path, "."));
103+
auto prql_fqid = fmt::to_string(fmt::join(ht.ht_prql_path, "."));
105104
lnav::sql::prql_functions.emplace(prql_fqid, &ht);
106105

107106
auto* curr_hier = &phier;

0 commit comments

Comments
 (0)