FaceRegistry: pass face names as StringViews instead of const String&

This commit is contained in:
Maxime Coste 2018-02-09 22:08:29 +11:00
parent e46a5697e5
commit cb16e52179
2 changed files with 6 additions and 6 deletions

View File

@ -71,7 +71,7 @@ String to_string(Face face)
return format("{},{}{}", face.fg, face.bg, face.attributes);
}
Face FaceRegistry::operator[](const String& facedesc)
Face FaceRegistry::operator[](StringView facedesc)
{
auto it = m_aliases.find(facedesc);
while (it != m_aliases.end())
@ -83,7 +83,7 @@ Face FaceRegistry::operator[](const String& facedesc)
return parse_face(facedesc);
}
void FaceRegistry::register_alias(const String& name, const String& facedesc,
void FaceRegistry::register_alias(StringView name, StringView facedesc,
bool override)
{
if (not override and m_aliases.find(name) != m_aliases.end())
@ -110,7 +110,7 @@ void FaceRegistry::register_alias(const String& name, const String& facedesc,
it = m_aliases.find(it->value.alias);
}
alias.alias = facedesc;
alias.alias = facedesc.str();
}
else
{

View File

@ -14,8 +14,8 @@ class FaceRegistry : public Singleton<FaceRegistry>
public:
FaceRegistry();
Face operator[](const String& facedesc);
void register_alias(const String& name, const String& facedesc,
Face operator[](StringView facedesc);
void register_alias(StringView name, StringView facedesc,
bool override = false);
CandidateList complete_alias_name(StringView prefix,
@ -34,7 +34,7 @@ private:
AliasMap m_aliases;
};
inline Face get_face(const String& facedesc)
inline Face get_face(StringView facedesc)
{
if (FaceRegistry::has_instance())
return FaceRegistry::instance()[facedesc];