From 8beda67fae3a57b450139037715122016bde2319 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 21 Apr 2014 10:50:09 +0100 Subject: [PATCH] Use StringView in FunctionGroup and FunctionRegistry --- src/function_group.hh | 12 ++++++------ src/function_registry.hh | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/function_group.hh b/src/function_group.hh index 3bac5159..025a8f92 100644 --- a/src/function_group.hh +++ b/src/function_group.hh @@ -33,23 +33,23 @@ public: m_functions.append(std::forward(function)); } - void remove(const String& id) + void remove(StringView id) { m_functions.remove(id); } - FunctionGroup& get_group(const String& path, Codepoint path_separator = 0) + FunctionGroup& get_group(StringView path, Codepoint path_separator = 0) { auto sep_it = std::find(path.begin(), path.end(), path_separator); - String id(path.begin(), sep_it); + StringView id(path.begin(), sep_it); auto it = m_functions.find(id); if (it == m_functions.end()) - throw group_not_found("no such id: " + id); + throw group_not_found("no such id: "_str + id); FunctionGroup* group = it->second.template target(); if (not group) - throw group_not_found("not a group: " + id); + throw group_not_found("not a group: "_str + id); if (sep_it != path.end()) - return group->get_group(String(sep_it+1, path.end()), path_separator); + return group->get_group(StringView(sep_it+1, path.end()), path_separator); else return *group; } diff --git a/src/function_registry.hh b/src/function_registry.hh index 2dbf1f02..1565c36a 100644 --- a/src/function_registry.hh +++ b/src/function_registry.hh @@ -18,13 +18,13 @@ template class FunctionRegistry { public: - void register_func(const String& name, const FunctionType& function) + void register_func(StringView name, const FunctionType& function) { kak_assert(not m_functions.contains(name)); m_functions.append(std::make_pair(name, function)); } - const FunctionType& operator[](const String& name) const + const FunctionType& operator[](StringView name) const { auto it = m_functions.find(name); if (it == m_functions.end())