Use StringView in BufferManager
This commit is contained in:
parent
97b08a6f09
commit
b2123547df
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user