Cache Webview::Availability() result for startup checks

Iv::ShowButton() and LocationPicker::Available() each called
Webview::Availability() separately (~200ms each on Linux). Replace
the per-caller static caches with a single shared cache in
Core::CachedWebviewAvailability(), reducing startup from two
~200ms calls to one.
This commit is contained in:
futpib
2026-02-18 14:44:39 +00:00
committed by John Preston
parent 1a35929eb8
commit ec7c76b8d2
5 changed files with 32 additions and 17 deletions
+4 -7
View File
@@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "iv/iv_data.h"
#include "iv/iv_prepare.h"
#include "webview/webview_interface.h"
#include "core/cached_webview_availability.h"
#include <QtCore/QRegularExpression>
#include <QtCore/QUrl>
@@ -102,12 +102,9 @@ QString SiteNameFromUrl(const QString &url) {
}
bool ShowButton() {
static const auto Supported = [&] {
const auto availability = Webview::Availability();
return availability.customSchemeRequests
&& availability.customRangeRequests;
}();
return Supported;
const auto &availability = Core::CachedWebviewAvailability();
return availability.customSchemeRequests
&& availability.customRangeRequests;
}
void RecordShowFailure() {