mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Remove a few useless .c_str()
With .c_str(), these call the wchar_t* overloads, which frequently then go on to call wcslen. Just directly use the wcstring we already have.
This commit is contained in:
parent
ff042bbb7b
commit
27c0ee92de
3 changed files with 5 additions and 5 deletions
|
@ -554,7 +554,7 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams
|
||||||
}
|
}
|
||||||
const wcstring value = vals[i];
|
const wcstring value = vals[i];
|
||||||
const wcstring escaped_val =
|
const wcstring escaped_val =
|
||||||
escape_string(value.c_str(), ESCAPE_NO_QUOTED, STRING_STYLE_SCRIPT);
|
escape_string(value, ESCAPE_NO_QUOTED, STRING_STYLE_SCRIPT);
|
||||||
streams.out.append_format(_(L"$%ls[%d]: length=%d value=|%ls|\n"), var_name, i + 1,
|
streams.out.append_format(_(L"$%ls[%d]: length=%d value=|%ls|\n"), var_name, i + 1,
|
||||||
value.size(), escaped_val.c_str());
|
value.size(), escaped_val.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,7 +429,7 @@ int builtin_status(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
}
|
}
|
||||||
case STATUS_FISH_PATH: {
|
case STATUS_FISH_PATH: {
|
||||||
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
|
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
|
||||||
streams.out.append(str2wcstring(get_executable_path("fish")).c_str());
|
streams.out.append(str2wcstring(get_executable_path("fish")));
|
||||||
streams.out.push_back(L'\n');
|
streams.out.push_back(L'\n');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,7 @@ static comp_info_list_t process_completions_into_infos(const completion_list_t &
|
||||||
}
|
}
|
||||||
|
|
||||||
void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &prefix) const {
|
void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &prefix) const {
|
||||||
size_t prefix_len = fish_wcswidth(prefix.c_str());
|
size_t prefix_len = fish_wcswidth(prefix);
|
||||||
for (size_t i = 0; i < infos->size(); i++) {
|
for (size_t i = 0; i < infos->size(); i++) {
|
||||||
comp_t *comp = &infos->at(i);
|
comp_t *comp = &infos->at(i);
|
||||||
const wcstring_list_t &comp_strings = comp->comp;
|
const wcstring_list_t &comp_strings = comp->comp;
|
||||||
|
@ -329,12 +329,12 @@ void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &
|
||||||
if (j >= 1) comp->comp_width += 2;
|
if (j >= 1) comp->comp_width += 2;
|
||||||
|
|
||||||
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
||||||
int comp_width = fish_wcswidth(comp_strings.at(j).c_str());
|
int comp_width = fish_wcswidth(comp_strings.at(j));
|
||||||
if (comp_width >= 0) comp->comp_width += prefix_len + comp_width;
|
if (comp_width >= 0) comp->comp_width += prefix_len + comp_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
||||||
int desc_width = fish_wcswidth(comp->desc.c_str());
|
int desc_width = fish_wcswidth(comp->desc);
|
||||||
comp->desc_width = desc_width > 0 ? desc_width : 0;
|
comp->desc_width = desc_width > 0 ? desc_width : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue