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/client_manager.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/client_manager.cc')
| -rw-r--r-- | src/client_manager.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/client_manager.cc b/src/client_manager.cc index 8d4f2de0..1548f502 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -44,7 +44,7 @@ String ClientManager::generate_name() const } } -Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui, int pid, +Client* ClientManager::create_client(UniquePtr<UserInterface>&& ui, int pid, String name, EnvVarMap env_vars, StringView init_cmds, StringView init_buffer, Optional<BufferCoord> init_coord, Client::OnExitCallback on_exit) @@ -156,7 +156,7 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) { return &ws.window->buffer() == &buffer; }); if (it == m_free_windows.rend()) - return { std::make_unique<Window>(buffer), { buffer, Selection{} } }; + return { make_unique_ptr<Window>(buffer), { buffer, Selection{} } }; WindowAndSelections res = std::move(*it); m_free_windows.erase(it.base()-1); @@ -164,7 +164,7 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) return res; } -void ClientManager::add_free_window(std::unique_ptr<Window>&& window, SelectionList selections) +void ClientManager::add_free_window(UniquePtr<Window>&& window, SelectionList selections) { if (not contains(BufferManager::instance(), &window->buffer())) { @@ -181,7 +181,7 @@ void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer) for (auto& client : m_clients) client->context().forget_buffer(buffer); - Vector<std::unique_ptr<Window>> removed_windows; + Vector<UniquePtr<Window>> removed_windows; m_free_windows.erase(remove_if(m_free_windows, [&buffer, &removed_windows](WindowAndSelections& ws) { if (&ws.window->buffer() != &buffer) @@ -240,7 +240,7 @@ void ClientManager::redraw_clients() const CandidateList ClientManager::complete_client_name(StringView prefix, ByteCount cursor_pos) const { - auto c = m_clients | transform([](const std::unique_ptr<Client>& c) -> const String& + auto c = m_clients | transform([](const UniquePtr<Client>& c) -> const String& { return c->context().name(); }); return complete(prefix, cursor_pos, c); } |
