mirror of
https://github.com/transmission/transmission.git
synced 2026-04-18 16:07:21 +01:00
perf: prune unused interned strings (#8653)
This commit is contained in:
@@ -54,6 +54,7 @@ auto const FDONotificationsInterfaceName = QStringLiteral("org.freedesktop.Notif
|
|||||||
auto constexpr StatsRefreshIntervalMsec = 3000;
|
auto constexpr StatsRefreshIntervalMsec = 3000;
|
||||||
auto constexpr SessionRefreshIntervalMsec = 3000;
|
auto constexpr SessionRefreshIntervalMsec = 3000;
|
||||||
auto constexpr ModelRefreshIntervalMsec = 3000;
|
auto constexpr ModelRefreshIntervalMsec = 3000;
|
||||||
|
auto constexpr InternRefreshIntervalMsec = 5 * 60 * 1000;
|
||||||
|
|
||||||
bool loadTranslation(QTranslator& translator, QString const& name, QLocale const& locale, QStringList const& search_directories)
|
bool loadTranslation(QTranslator& translator, QString const& name, QLocale const& locale, QStringList const& search_directories)
|
||||||
{
|
{
|
||||||
@@ -127,6 +128,16 @@ QAccessibleInterface* accessibleFactory(QString const& className, QObject* objec
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
void Application::pruneInternedStrings()
|
||||||
|
{
|
||||||
|
std::erase_if(interned_strings_, [](QString const& str) { return str.isDetached(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Application::intern(QString const& in)
|
||||||
|
{
|
||||||
|
return *interned_strings_.insert(in).first;
|
||||||
|
}
|
||||||
|
|
||||||
Application::Application(
|
Application::Application(
|
||||||
Prefs& prefs,
|
Prefs& prefs,
|
||||||
RpcClient& rpc,
|
RpcClient& rpc,
|
||||||
@@ -203,6 +214,12 @@ Application::Application(
|
|||||||
timer->setInterval(SessionRefreshIntervalMsec);
|
timer->setInterval(SessionRefreshIntervalMsec);
|
||||||
timer->start();
|
timer->start();
|
||||||
|
|
||||||
|
timer = &intern_timer_;
|
||||||
|
connect(timer, &QTimer::timeout, this, &Application::pruneInternedStrings);
|
||||||
|
timer->setSingleShot(false);
|
||||||
|
timer->setInterval(InternRefreshIntervalMsec);
|
||||||
|
timer->start();
|
||||||
|
|
||||||
maybeUpdateBlocklist();
|
maybeUpdateBlocklist();
|
||||||
|
|
||||||
if (!first_time)
|
if (!first_time)
|
||||||
|
|||||||
@@ -54,10 +54,7 @@ public:
|
|||||||
void raise() const;
|
void raise() const;
|
||||||
bool notifyApp(QString const& title, QString const& body, QStringList const& actions = {}) const;
|
bool notifyApp(QString const& title, QString const& body, QStringList const& actions = {}) const;
|
||||||
|
|
||||||
QString const& intern(QString const& in)
|
QString intern(QString const& in);
|
||||||
{
|
|
||||||
return *interned_strings_.insert(in).first;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] QPixmap find_favicon(QString const& sitename) const
|
[[nodiscard]] QPixmap find_favicon(QString const& sitename) const
|
||||||
{
|
{
|
||||||
@@ -94,6 +91,7 @@ private slots:
|
|||||||
void onTorrentsCompleted(torrent_ids_t const& torrent_ids) const;
|
void onTorrentsCompleted(torrent_ids_t const& torrent_ids) const;
|
||||||
void onTorrentsEdited(torrent_ids_t const& torrent_ids) const;
|
void onTorrentsEdited(torrent_ids_t const& torrent_ids) const;
|
||||||
void onTorrentsNeedInfo(torrent_ids_t const& torrent_ids) const;
|
void onTorrentsNeedInfo(torrent_ids_t const& torrent_ids) const;
|
||||||
|
void pruneInternedStrings();
|
||||||
void refreshPref(int key) const;
|
void refreshPref(int key) const;
|
||||||
void refreshTorrents();
|
void refreshTorrents();
|
||||||
void saveGeometry() const;
|
void saveGeometry() const;
|
||||||
@@ -117,6 +115,7 @@ private:
|
|||||||
QTimer model_timer_;
|
QTimer model_timer_;
|
||||||
QTimer stats_timer_;
|
QTimer stats_timer_;
|
||||||
QTimer session_timer_;
|
QTimer session_timer_;
|
||||||
|
QTimer intern_timer_;
|
||||||
time_t last_full_update_time_ = {};
|
time_t last_full_update_time_ = {};
|
||||||
QTranslator qt_translator_;
|
QTranslator qt_translator_;
|
||||||
QTranslator app_translator_;
|
QTranslator app_translator_;
|
||||||
|
|||||||
Reference in New Issue
Block a user