micro-opt Color construction

toLower call not necessary, NamedColors is case-insensitive
This commit is contained in:
Kae 2024-04-23 11:49:25 +10:00
parent 7136c929ce
commit c24fc5aeaf

View File

@ -214,10 +214,10 @@ Color Color::gray(uint8_t g) {
Color::Color() {} Color::Color() {}
Color::Color(StringView name) { Color::Color(StringView name) {
if (name.beginsWith('#')) if (name.utf8().rfind('#', 0) == 0)
*this = fromHex(name.substr(1)); *this = fromHex(name.utf8().substr(1));
else { else {
auto i = NamedColors.find(String(name).toLower()); auto i = NamedColors.find(String(name));
if (i != NamedColors.end()) if (i != NamedColors.end())
*this = i->second; *this = i->second;
else else