From 33a5419350bb390777ebacd0c198b3cda9f04960 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sun, 18 May 2025 17:30:02 +0200 Subject: [PATCH] Forward declare some things to speed up compile (#6162) * Forward declare NativeMessagingServer and use a unique_ptr * Forward declare GenericListModel to save on unneeded includes of its header --- src/Application.cpp | 4 +++- src/Application.hpp | 5 ++--- src/controllers/completion/sources/CommandSource.cpp | 1 + src/controllers/completion/sources/EmoteSource.cpp | 1 + src/controllers/completion/sources/Source.hpp | 9 +++------ src/controllers/completion/sources/UnifiedSource.cpp | 2 ++ src/controllers/completion/sources/UserSource.cpp | 1 + 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index d8ae6606..beca437f 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -20,6 +20,7 @@ #include "providers/twitch/eventsub/Controller.hpp" #include "providers/twitch/TwitchBadges.hpp" #include "singletons/ImageUploader.hpp" +#include "singletons/NativeMessaging.hpp" #ifdef CHATTERINO_HAVE_PLUGINS # include "controllers/plugins/PluginController.hpp" #endif @@ -197,6 +198,7 @@ Application::Application(Settings &_settings, const Paths &paths, #ifdef CHATTERINO_HAVE_PLUGINS , plugins(new PluginController(paths)) #endif + , nmServer(new NativeMessagingServer()) , updates(_updates) { } @@ -655,7 +657,7 @@ void Application::initNm(const Paths &paths) #if defined QT_NO_DEBUG || defined CHATTERINO_DEBUG_NM registerNmHost(paths); - this->nmServer.start(); + this->nmServer->start(); #endif } diff --git a/src/Application.hpp b/src/Application.hpp index d00935f9..fb717229 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -1,7 +1,5 @@ #pragma once -#include "singletons/NativeMessaging.hpp" - #include #include @@ -54,6 +52,7 @@ class SeventvEventAPI; class ILinkResolver; class IStreamerMode; class ITwitchUsers; +class NativeMessagingServer; namespace pronouns { class Pronouns; } // namespace pronouns @@ -236,7 +235,7 @@ public: private: void initNm(const Paths &paths); - NativeMessagingServer nmServer; + std::unique_ptr nmServer; Updates &updates; bool initialized{false}; diff --git a/src/controllers/completion/sources/CommandSource.cpp b/src/controllers/completion/sources/CommandSource.cpp index 29deff93..14378a62 100644 --- a/src/controllers/completion/sources/CommandSource.cpp +++ b/src/controllers/completion/sources/CommandSource.cpp @@ -5,6 +5,7 @@ #include "controllers/commands/CommandController.hpp" #include "controllers/completion/sources/Helpers.hpp" #include "providers/twitch/TwitchCommon.hpp" +#include "widgets/splits/InputCompletionItem.hpp" namespace chatterino::completion { diff --git a/src/controllers/completion/sources/EmoteSource.cpp b/src/controllers/completion/sources/EmoteSource.cpp index 9aab5121..7d75582c 100644 --- a/src/controllers/completion/sources/EmoteSource.cpp +++ b/src/controllers/completion/sources/EmoteSource.cpp @@ -11,6 +11,7 @@ #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchIrcServer.hpp" #include "singletons/Emotes.hpp" +#include "widgets/splits/InputCompletionItem.hpp" namespace chatterino::completion { diff --git a/src/controllers/completion/sources/Source.hpp b/src/controllers/completion/sources/Source.hpp index b78ce06e..a620103f 100644 --- a/src/controllers/completion/sources/Source.hpp +++ b/src/controllers/completion/sources/Source.hpp @@ -1,13 +1,10 @@ #pragma once -#include "widgets/listview/GenericListModel.hpp" -#include "widgets/splits/InputCompletionItem.hpp" - #include -#include -#include -#include +namespace chatterino { +class GenericListModel; +} // namespace chatterino namespace chatterino::completion { diff --git a/src/controllers/completion/sources/UnifiedSource.cpp b/src/controllers/completion/sources/UnifiedSource.cpp index 6d8dfe15..8006fbe1 100644 --- a/src/controllers/completion/sources/UnifiedSource.cpp +++ b/src/controllers/completion/sources/UnifiedSource.cpp @@ -1,5 +1,7 @@ #include "controllers/completion/sources/UnifiedSource.hpp" +#include "widgets/listview/GenericListModel.hpp" + namespace chatterino::completion { UnifiedSource::UnifiedSource(std::vector> sources) diff --git a/src/controllers/completion/sources/UserSource.cpp b/src/controllers/completion/sources/UserSource.cpp index d700ef25..3be00324 100644 --- a/src/controllers/completion/sources/UserSource.cpp +++ b/src/controllers/completion/sources/UserSource.cpp @@ -4,6 +4,7 @@ #include "providers/twitch/TwitchChannel.hpp" #include "singletons/Settings.hpp" #include "util/Helpers.hpp" +#include "widgets/splits/InputCompletionItem.hpp" namespace chatterino::completion {