mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Remove repeated calculation of fixed string's length in a loop
This commit is contained in:
parent
b8a16a8ba0
commit
e628ba51e7
1 changed files with 5 additions and 2 deletions
|
@ -474,14 +474,17 @@ rgb_color_t parse_color(const env_var_t &var, bool is_background) {
|
|||
|
||||
std::vector<rgb_color_t> candidates;
|
||||
|
||||
static const wchar_t *prefix = L"--background=";
|
||||
// wcslen is not available as constexpr
|
||||
static auto prefix_len = wcslen(prefix);
|
||||
|
||||
wcstring color_name;
|
||||
for (const wcstring &next : var.as_list()) {
|
||||
color_name.clear();
|
||||
if (is_background) {
|
||||
// Look for something like "--background=red".
|
||||
const wchar_t *prefix = L"--background=";
|
||||
if (string_prefixes_string(prefix, next)) {
|
||||
color_name = wcstring(next, wcslen(prefix));
|
||||
color_name = wcstring(next, prefix_len);
|
||||
}
|
||||
// Reverse should be meaningful in either context
|
||||
if (next == L"--reverse" || next == L"-r") {
|
||||
|
|
Loading…
Reference in a new issue