Buffer: avoid expensive option flattening in on_registred with NoHooks

This commit is contained in:
Maxime Coste 2018-02-18 14:48:24 +11:00
parent 82c8a6e9dd
commit 10c6c59a26
2 changed files with 8 additions and 2 deletions

View File

@ -107,6 +107,12 @@ void Buffer::on_registered()
options().register_watcher(*this);
if (m_flags & Buffer::Flags::NoHooks)
{
on_option_changed(options()["readonly"]);
return;
}
run_hook_in_own_context("BufCreate", m_name);
if (m_flags & Flags::File)

View File

@ -772,7 +772,7 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView
for (auto& file : files)
{
Buffer* buffer = open_file_buffer(file);
Buffer* buffer = open_file_buffer(file, Buffer::Flags::NoHooks);
if (not suffix_backup.empty())
write_buffer_to_file(*buffer, buffer->name() + suffix_backup);
apply_to_buffer(*buffer);
@ -782,7 +782,7 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView
if (not isatty(0))
{
Buffer& buffer = *buffer_manager.create_buffer(
"*stdin*", Buffer::Flags::None, read_fd(0), InvalidTime);
"*stdin*", Buffer::Flags::NoHooks, read_fd(0), InvalidTime);
apply_to_buffer(buffer);
write_buffer_to_fd(buffer, 1);
buffer_manager.delete_buffer(buffer);