mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 20:55:15 +08:00
expand: Use wcstring for the abbr prefix
This mainly is conceptually a bit simpler. The comment about making it cheaper is entirely misplaced since this is quite far away from being important. Even expanding 1000 abbrs, it doesn't show up in the profile.
This commit is contained in:
parent
212246ecaa
commit
9a541d9ed4
|
@ -1217,13 +1217,12 @@ maybe_t<wcstring> expand_abbreviation(const wcstring &src, const environment_t &
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<wcstring, wcstring> get_abbreviations(const environment_t &vars) {
|
std::map<wcstring, wcstring> get_abbreviations(const environment_t &vars) {
|
||||||
// TODO: try to make this cheaper
|
const wcstring prefix = L"_fish_abbr_";
|
||||||
const size_t fish_abbr_len = std::wcslen(L"_fish_abbr_");
|
|
||||||
auto names = vars.get_names(0);
|
auto names = vars.get_names(0);
|
||||||
std::map<wcstring, wcstring> result;
|
std::map<wcstring, wcstring> result;
|
||||||
for (const wcstring &name : names) {
|
for (const wcstring &name : names) {
|
||||||
if (string_prefixes_string(L"_fish_abbr_", name)) {
|
if (string_prefixes_string(prefix, name)) {
|
||||||
result[name.substr(fish_abbr_len)] = vars.get(name)->as_string();
|
result[name.substr(prefix.size())] = vars.get(name)->as_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user