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/main.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc index 60c0669e..8cf3349a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -213,7 +213,7 @@ static const EnvVarDesc builtin_env_vars[] = { { "client_list", false, [](StringView name, const Context& context) -> Vector { return ClientManager::instance() | - transform([](const std::unique_ptr& c) -> const String& + transform([](const UniquePtr& c) -> const String& { return c->context().name(); }) | gather>(); } }, { "modified", false, @@ -333,10 +333,10 @@ void register_registers() RegisterManager& register_manager = RegisterManager::instance(); for (Codepoint c : StringView{"abcdefghijklmnopqrstuvwxyz\"^@"}) - register_manager.add_register(c, std::make_unique(String{c})); + register_manager.add_register(c, make_unique_ptr(String{c})); for (Codepoint c : StringView{"/|:\\"}) - register_manager.add_register(c, std::make_unique(String{c})); + register_manager.add_register(c, make_unique_ptr(String{c})); using StringList = Vector; @@ -388,7 +388,7 @@ void register_registers() })); } - register_manager.add_register('_', std::make_unique()); + register_manager.add_register('_', make_unique_ptr()); } void register_keymaps() @@ -551,7 +551,7 @@ UIType parse_ui_type(StringView ui_name) throw parameter_error(format("error: unknown ui type: '{}'", ui_name)); } -std::unique_ptr make_ui(UIType ui_type) +UniquePtr make_ui(UIType ui_type) { struct DummyUI : UserInterface { @@ -577,9 +577,9 @@ std::unique_ptr make_ui(UIType ui_type) switch (ui_type) { - case UIType::Terminal: return std::make_unique(); - case UIType::Json: return std::make_unique(); - case UIType::Dummy: return std::make_unique(); + case UIType::Terminal: return make_unique_ptr(); + case UIType::Json: return make_unique_ptr(); + case UIType::Dummy: return make_unique_ptr(); } throw logic_error{}; } @@ -598,7 +598,7 @@ pid_t fork_server_to_background() return 0; } -std::unique_ptr create_local_ui(UIType ui_type) +UniquePtr create_local_ui(UIType ui_type) { auto ui = make_ui(ui_type); -- cgit v1.2.3