From 9a541d9ed468ddb2314443ac721b25d8cc7ebf12 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 22 May 2019 22:31:45 +0200 Subject: [PATCH] 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. --- src/expand.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/expand.cpp b/src/expand.cpp index 1cc38b00d..eb3982dc8 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -1217,13 +1217,12 @@ maybe_t expand_abbreviation(const wcstring &src, const environment_t & } std::map get_abbreviations(const environment_t &vars) { - // TODO: try to make this cheaper - const size_t fish_abbr_len = std::wcslen(L"_fish_abbr_"); + const wcstring prefix = L"_fish_abbr_"; auto names = vars.get_names(0); std::map result; for (const wcstring &name : names) { - if (string_prefixes_string(L"_fish_abbr_", name)) { - result[name.substr(fish_abbr_len)] = vars.get(name)->as_string(); + if (string_prefixes_string(prefix, name)) { + result[name.substr(prefix.size())] = vars.get(name)->as_string(); } } return result;