From d3d3f7dbb3497c8b9ed0053957678de449a270b4 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 17 Apr 2020 12:37:53 +0800 Subject: [PATCH] Add final specifier to classes This allow compilers to generate more efficient code. --- src/app/application.h | 2 +- src/app/qtlocalpeer/qtlockedfile.h | 2 +- src/base/bittorrent/private/filterparserthread.h | 2 +- src/base/bittorrent/private/nativesessionextension.h | 2 +- src/base/bittorrent/private/nativetorrentextension.h | 2 +- src/base/bittorrent/private/portforwarderimpl.h | 2 +- src/base/bittorrent/torrentcreatorthread.h | 2 +- src/base/bittorrent/tracker.h | 2 +- src/base/http/server.h | 2 +- src/base/net/downloadmanager.cpp | 2 +- src/base/net/private/downloadhandlerimpl.h | 2 +- src/base/private/profile_p.h | 8 ++++---- src/base/rss/private/rss_parser.cpp | 2 +- src/base/scanfoldersmodel.h | 2 +- src/webui/webapplication.h | 4 ++-- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/app/application.h b/src/app/application.h index 777a6ec97..afa66084d 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -68,7 +68,7 @@ namespace RSS class AutoDownloader; } -class Application : public BaseApplication +class Application final : public BaseApplication { Q_OBJECT Q_DISABLE_COPY(Application) diff --git a/src/app/qtlocalpeer/qtlockedfile.h b/src/app/qtlocalpeer/qtlockedfile.h index 11f0b3b95..e97b4c761 100644 --- a/src/app/qtlocalpeer/qtlockedfile.h +++ b/src/app/qtlocalpeer/qtlockedfile.h @@ -77,7 +77,7 @@ namespace QtLP_Private { - class QtLockedFile : public QFile + class QtLockedFile final : public QFile { public: enum LockMode diff --git a/src/base/bittorrent/private/filterparserthread.h b/src/base/bittorrent/private/filterparserthread.h index f7e93379d..6467af3f2 100644 --- a/src/base/bittorrent/private/filterparserthread.h +++ b/src/base/bittorrent/private/filterparserthread.h @@ -35,7 +35,7 @@ class QDataStream; -class FilterParserThread : public QThread +class FilterParserThread final : public QThread { Q_OBJECT diff --git a/src/base/bittorrent/private/nativesessionextension.h b/src/base/bittorrent/private/nativesessionextension.h index 0e0aa4c7c..9dd5f6a32 100644 --- a/src/base/bittorrent/private/nativesessionextension.h +++ b/src/base/bittorrent/private/nativesessionextension.h @@ -31,7 +31,7 @@ #include #include -class NativeSessionExtension : public lt::plugin +class NativeSessionExtension final : public lt::plugin { #if (LIBTORRENT_VERSION_NUM >= 10200) lt::feature_flags_t implemented_features() override; diff --git a/src/base/bittorrent/private/nativetorrentextension.h b/src/base/bittorrent/private/nativetorrentextension.h index 46a7759ca..d197bd736 100644 --- a/src/base/bittorrent/private/nativetorrentextension.h +++ b/src/base/bittorrent/private/nativetorrentextension.h @@ -32,7 +32,7 @@ #include #include -class NativeTorrentExtension : public lt::torrent_plugin +class NativeTorrentExtension final : public lt::torrent_plugin { public: explicit NativeTorrentExtension(const lt::torrent_handle &torrentHandle); diff --git a/src/base/bittorrent/private/portforwarderimpl.h b/src/base/bittorrent/private/portforwarderimpl.h index 025984a59..2c6f584e5 100644 --- a/src/base/bittorrent/private/portforwarderimpl.h +++ b/src/base/bittorrent/private/portforwarderimpl.h @@ -44,7 +44,7 @@ using LTPortMapping = int; using LTPortMapping = lt::port_mapping_t; #endif -class PortForwarderImpl : public Net::PortForwarder +class PortForwarderImpl final : public Net::PortForwarder { Q_OBJECT Q_DISABLE_COPY(PortForwarderImpl) diff --git a/src/base/bittorrent/torrentcreatorthread.h b/src/base/bittorrent/torrentcreatorthread.h index 523e3a42d..50c3779b3 100644 --- a/src/base/bittorrent/torrentcreatorthread.h +++ b/src/base/bittorrent/torrentcreatorthread.h @@ -48,7 +48,7 @@ namespace BitTorrent QStringList urlSeeds; }; - class TorrentCreatorThread : public QThread + class TorrentCreatorThread final : public QThread { Q_OBJECT diff --git a/src/base/bittorrent/tracker.h b/src/base/bittorrent/tracker.h index a843f5f58..37ea294bf 100644 --- a/src/base/bittorrent/tracker.h +++ b/src/base/bittorrent/tracker.h @@ -70,7 +70,7 @@ namespace BitTorrent // *Basic* Bittorrent tracker implementation // [BEP-3] The BitTorrent Protocol Specification // also see: https://wiki.theory.org/index.php/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol - class Tracker : public QObject, public Http::IRequestHandler, private Http::ResponseBuilder + class Tracker final : public QObject, public Http::IRequestHandler, private Http::ResponseBuilder { Q_OBJECT Q_DISABLE_COPY(Tracker) diff --git a/src/base/http/server.h b/src/base/http/server.h index 8bd7c8589..7e3cef5c2 100644 --- a/src/base/http/server.h +++ b/src/base/http/server.h @@ -41,7 +41,7 @@ namespace Http class IRequestHandler; class Connection; - class Server : public QTcpServer + class Server final : public QTcpServer { Q_OBJECT Q_DISABLE_COPY(Server) diff --git a/src/base/net/downloadmanager.cpp b/src/base/net/downloadmanager.cpp index 0b90edc36..f25e71a15 100644 --- a/src/base/net/downloadmanager.cpp +++ b/src/base/net/downloadmanager.cpp @@ -52,7 +52,7 @@ namespace // Disguise as Firefox to avoid web server banning const char DEFAULT_USER_AGENT[] = "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0"; - class NetworkCookieJar : public QNetworkCookieJar + class NetworkCookieJar final : public QNetworkCookieJar { public: explicit NetworkCookieJar(QObject *parent = nullptr) diff --git a/src/base/net/private/downloadhandlerimpl.h b/src/base/net/private/downloadhandlerimpl.h index 9e8b36565..1a1c6e5ac 100644 --- a/src/base/net/private/downloadhandlerimpl.h +++ b/src/base/net/private/downloadhandlerimpl.h @@ -36,7 +36,7 @@ class QObject; class QUrl; -class DownloadHandlerImpl : public Net::DownloadHandler +class DownloadHandlerImpl final : public Net::DownloadHandler { Q_OBJECT Q_DISABLE_COPY(DownloadHandlerImpl) diff --git a/src/base/private/profile_p.h b/src/base/private/profile_p.h index 57ae0a91c..683267797 100644 --- a/src/base/private/profile_p.h +++ b/src/base/private/profile_p.h @@ -63,7 +63,7 @@ namespace Private }; /// Default implementation. Takes paths from system - class DefaultProfile : public Profile + class DefaultProfile final : public Profile { public: explicit DefaultProfile(const QString &configurationName); @@ -86,7 +86,7 @@ namespace Private }; /// Custom tree: creates directories under the specified root directory - class CustomProfile : public Profile + class CustomProfile final : public Profile { public: CustomProfile(const QString &rootPath, const QString &configurationName); @@ -114,14 +114,14 @@ namespace Private virtual ~PathConverter() = default; }; - class NoConvertConverter : public PathConverter + class NoConvertConverter final : public PathConverter { public: QString toPortablePath(const QString &path) const override; QString fromPortablePath(const QString &portablePath) const override; }; - class Converter : public PathConverter + class Converter final : public PathConverter { public: explicit Converter(const QString &basePath); diff --git a/src/base/rss/private/rss_parser.cpp b/src/base/rss/private/rss_parser.cpp index 2b2bb7da8..c4ca757c1 100644 --- a/src/base/rss/private/rss_parser.cpp +++ b/src/base/rss/private/rss_parser.cpp @@ -44,7 +44,7 @@ namespace { - class XmlStreamEntityResolver : public QXmlStreamEntityResolver + class XmlStreamEntityResolver final : public QXmlStreamEntityResolver { public: QString resolveUndeclaredEntity(const QString &name) override diff --git a/src/base/scanfoldersmodel.h b/src/base/scanfoldersmodel.h index 38bc13569..ad78fb2c3 100644 --- a/src/base/scanfoldersmodel.h +++ b/src/base/scanfoldersmodel.h @@ -36,7 +36,7 @@ class QStringList; class FileSystemWatcher; -class ScanFoldersModel : public QAbstractListModel +class ScanFoldersModel final : public QAbstractListModel { Q_OBJECT Q_DISABLE_COPY(ScanFoldersModel) diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index 2fa213f2f..fb70e11a7 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -50,7 +50,7 @@ class WebApplication; constexpr char C_SID[] = "SID"; // name of session id cookie -class WebSession : public ISession +class WebSession final : public ISession { public: explicit WebSession(const QString &sid); @@ -69,7 +69,7 @@ private: QVariantHash m_data; }; -class WebApplication +class WebApplication final : public QObject, public Http::IRequestHandler, public ISessionManager , private Http::ResponseBuilder {