Optimize parse_color

This commit is contained in:
ridiculousfish 2019-09-21 19:36:56 -07:00
parent 902c6ec4a3
commit 70a1d8314c

View File

@ -466,17 +466,14 @@ rgb_color_t parse_color(const env_var_t &var, bool is_background) {
std::vector<rgb_color_t> candidates; std::vector<rgb_color_t> candidates;
wcstring_list_t el; wcstring color_name;
var.to_list(el); for (const wcstring &next : var.as_list()) {
color_name.clear();
for (size_t j = 0; j < el.size(); j++) {
const wcstring &next = el.at(j);
wcstring color_name;
if (is_background) { if (is_background) {
// Look for something like "--background=red". // Look for something like "--background=red".
const wcstring prefix = L"--background="; const wchar_t *prefix = L"--background=";
if (string_prefixes_string(prefix, next)) { if (string_prefixes_string(prefix, next)) {
color_name = wcstring(next, prefix.size()); color_name = wcstring(next, wcslen(prefix));
} }
} else { } else {
if (next == L"--bold" || next == L"-o") if (next == L"--bold" || next == L"-o")