diff --git a/src/core/Buffer.h b/src/core/Buffer.h index 24595ca..e70a872 100644 --- a/src/core/Buffer.h +++ b/src/core/Buffer.h @@ -119,7 +119,9 @@ public: m_cursors.push_back(iterator); return iterator; } + void clear() { m_gap_buffer->clear(); } auto get_string() { return m_gap_buffer->get_string(); } + void set_string(const std::string & s) { m_gap_buffer->set_string(s); } size_t size() const { return m_gap_buffer->size(); } uint8_t * address(size_t offset) const { return m_gap_buffer->address(offset); } Encoding::Type encoding() const { return m_encoding; } diff --git a/src/core/GapBuffer.cc b/src/core/GapBuffer.cc index a541b27..aea4cfd 100644 --- a/src/core/GapBuffer.cc +++ b/src/core/GapBuffer.cc @@ -62,7 +62,7 @@ std::string GapBuffer::get_string() return std::string((char *)m_buffer, m_size); } -void GapBuffer::set_string(std::string s) +void GapBuffer::set_string(const std::string & s) { clear(); insert(0u, (const uint8_t *)s.c_str(), s.size()); diff --git a/src/core/GapBuffer.h b/src/core/GapBuffer.h index a6017c1..cd49261 100644 --- a/src/core/GapBuffer.h +++ b/src/core/GapBuffer.h @@ -72,7 +72,7 @@ public: /** * Replace the buffer contents with a string. */ - void set_string(std::string s); + void set_string(const std::string & s); /** * Get the size of the data stored within the buffer.