From ce1d512a0c1922ab5f43f28e7bae573508c98601 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 8 Jul 2025 11:43:17 +1000 Subject: Replace std::unique_ptr with a custom implementation 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. --- src/client_manager.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/client_manager.cc') 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&& ui, int pid, +Client* ClientManager::create_client(UniquePtr&& ui, int pid, String name, EnvVarMap env_vars, StringView init_cmds, StringView init_buffer, Optional 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(buffer), { buffer, Selection{} } }; + return { make_unique_ptr(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, SelectionList selections) +void ClientManager::add_free_window(UniquePtr&& 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> removed_windows; + Vector> 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& c) -> const String& + auto c = m_clients | transform([](const UniquePtr& c) -> const String& { return c->context().name(); }); return complete(prefix, cursor_pos, c); } -- cgit v1.2.3