From cb16e52179f0d3c2fbd2f39f1c4eb43f2c97e0d2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 9 Feb 2018 22:08:29 +1100 Subject: [PATCH] FaceRegistry: pass face names as StringViews instead of const String& --- src/face_registry.cc | 6 +++--- src/face_registry.hh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/face_registry.cc b/src/face_registry.cc index fa35be4bf..65e5506b9 100644 --- a/src/face_registry.cc +++ b/src/face_registry.cc @@ -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 { diff --git a/src/face_registry.hh b/src/face_registry.hh index e6e276aa5..82006bd20 100644 --- a/src/face_registry.hh +++ b/src/face_registry.hh @@ -14,8 +14,8 @@ class FaceRegistry : public Singleton 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];