From b2123547df158250fdbfc8a445b91327808a8a5c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 19 Apr 2014 09:53:37 +0100 Subject: [PATCH] Use StringView in BufferManager --- src/buffer_manager.cc | 10 +++++----- src/buffer_manager.hh | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index a7175d7e..7660d2be 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -21,7 +21,7 @@ BufferManager::~BufferManager() void BufferManager::register_buffer(Buffer& buffer) { - const String& name = buffer.name(); + StringView name = buffer.name(); for (auto& buf : m_buffers) { if (buf->name() == name) @@ -59,13 +59,13 @@ void BufferManager::delete_buffer(Buffer& buffer) kak_assert(false); } -void BufferManager::delete_buffer_if_exists(const String& name) +void BufferManager::delete_buffer_if_exists(StringView name) { if (Buffer* buf = get_buffer_ifp(name)) delete_buffer(*buf); } -Buffer* BufferManager::get_buffer_ifp(const String& name) +Buffer* BufferManager::get_buffer_ifp(StringView name) { for (auto& buf : m_buffers) { @@ -77,11 +77,11 @@ Buffer* BufferManager::get_buffer_ifp(const String& name) return nullptr; } -Buffer& BufferManager::get_buffer(const String& name) +Buffer& BufferManager::get_buffer(StringView name) { Buffer* res = get_buffer_ifp(name); if (not res) - throw runtime_error("no such buffer '" + name + "'"); + throw runtime_error("no such buffer '"_str + name + "'"); return *res; } diff --git a/src/buffer_manager.hh b/src/buffer_manager.hh index 287ef672..a1001ffd 100644 --- a/src/buffer_manager.hh +++ b/src/buffer_manager.hh @@ -23,14 +23,14 @@ public: void unregister_buffer(Buffer& buffer); void delete_buffer(Buffer& buffer); - void delete_buffer_if_exists(const String& name); + void delete_buffer_if_exists(StringView name); iterator begin() const { return m_buffers.cbegin(); } iterator end() const { return m_buffers.cend(); } size_t count() const { return m_buffers.size(); } - Buffer* get_buffer_ifp(const String& name); - Buffer& get_buffer(const String& name); + Buffer* get_buffer_ifp(StringView name); + Buffer& get_buffer(StringView name); void set_last_used_buffer(Buffer& buffer); CandidateList complete_buffer_name(StringView prefix,