diff options
| author | Maxime Coste <mawww@kakoune.org> | 2025-07-08 11:43:17 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-07-08 12:07:33 +1000 |
| commit | ce1d512a0c1922ab5f43f28e7bae573508c98601 (patch) | |
| tree | 7af8effd6b00c304cda1c87f657a0014fcdae2ae /src/commands.cc | |
| parent | fea08fc18d268ace4f843ec2b57cc33e36562098 (diff) | |
Replace std::unique_ptr with a custom implementation
<memory> is a costly header we can avoid by just implementing
UniquePtr ourselves, which is a pretty straightforward in modern
C++, this saves around 10% of the compilation time here.
Diffstat (limited to 'src/commands.cc')
| -rw-r--r-- | src/commands.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/commands.cc b/src/commands.cc index e7faf5ec..351134f2 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -707,7 +707,7 @@ const CommandDesc write_all_cmd = { static void ensure_all_buffers_are_saved() { - auto is_modified = [](const std::unique_ptr<Buffer>& buf) { + auto is_modified = [](const UniquePtr<Buffer>& buf) { return (buf->flags() & Buffer::Flags::File) and buf->is_modified(); }; @@ -899,7 +899,7 @@ void cycle_buffer(const ParametersParser& parser, Context& context, const ShellC { Buffer* oldbuf = &context.buffer(); auto it = find_if(BufferManager::instance(), - [oldbuf](const std::unique_ptr<Buffer>& lhs) + [oldbuf](const UniquePtr<Buffer>& lhs) { return lhs.get() == oldbuf; }); kak_assert(it != BufferManager::instance().end()); @@ -2093,7 +2093,7 @@ void context_wrap(const ParametersParser& parser, Context& context, StringView d if (*bufnames == "*") { for (auto&& buffer : BufferManager::instance() - | transform(&std::unique_ptr<Buffer>::get) + | transform(&UniquePtr<Buffer>::get) | filter([](Buffer* buf) { return not (buf->flags() & Buffer::Flags::Debug); }) | gather<Vector<SafePtr<Buffer>>>()) // gather as we might be mutating the buffer list in the loop. context_wrap_for_buffer(*buffer); @@ -2197,7 +2197,7 @@ void context_wrap(const ParametersParser& parser, Context& context, StringView d if (*client_names == "*") { for (auto&& client : ClientManager::instance() - | transform(&std::unique_ptr<Client>::get) + | transform(&UniquePtr<Client>::get) | gather<Vector<SafePtr<Client>>>()) // gather as we might be mutating the client list in the loop. context_wrap_for_context(client->context()); } |
