summaryrefslogtreecommitdiff
path: root/src/buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-06-29 13:19:29 +0200
committerMaxime Coste <frrrwww@gmail.com>2012-06-29 13:19:29 +0200
commit49e1d918043c656dde9500ba7e09de173c8fef4a (patch)
tree720df980110d99e973f7279154ae0285f9ed3247 /src/buffer.cc
parent36e4dacdf5e33b9d92ea59124ef67a040b5392cb (diff)
Buffer: pass by value instead of by reference when object will be copied anyway
Let copy elision and move semantics kick in
Diffstat (limited to 'src/buffer.cc')
-rw-r--r--src/buffer.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index 4c29837a..a342ac07 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -21,9 +21,9 @@ T clamp(T min, T max, T val)
return val;
}
-Buffer::Buffer(const String& name, Type type,
- const String& initial_content)
- : m_name(name), m_type(type),
+Buffer::Buffer(String name, Type type,
+ String initial_content)
+ : m_name(std::move(name)), m_type(type),
m_history(1), m_history_cursor(m_history.begin()),
m_last_save_undo_index(0),
m_hook_manager(GlobalHookManager::instance()),
@@ -31,14 +31,14 @@ Buffer::Buffer(const String& name, Type type,
{
BufferManager::instance().register_buffer(this);
if (not initial_content.empty())
- apply_modification(Modification::make_insert(begin(), initial_content));
+ apply_modification(Modification::make_insert(begin(), std::move(initial_content)));
if (type == Type::NewFile)
- m_hook_manager.run_hook("BufNew", name, Context(*this));
+ m_hook_manager.run_hook("BufNew", m_name, Context(*this));
else if (type == Type::File)
- m_hook_manager.run_hook("BufOpen", name, Context(*this));
+ m_hook_manager.run_hook("BufOpen", m_name, Context(*this));
- m_hook_manager.run_hook("BufCreate", name, Context(*this));
+ m_hook_manager.run_hook("BufCreate", m_name, Context(*this));
}
Buffer::~Buffer()