From 09fba5cf3657c19c38e897a11a015d45b4328ae3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 4 Jun 2020 17:39:20 +0200 Subject: QWindowsFontDatabase: port local QSets to QDuplicateTracker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. Change-Id: I155f5518190c5f8f6d21fbec3fcecd6bcc7ff852 Reviewed-by: Qt CI Bot Reviewed-by: MÃ¥rten Nordheim --- src/gui/text/windows/qwindowsfontdatabase.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/gui/text/windows/qwindowsfontdatabase.cpp') diff --git a/src/gui/text/windows/qwindowsfontdatabase.cpp b/src/gui/text/windows/qwindowsfontdatabase.cpp index 58ff99e3a8..c89039ac58 100644 --- a/src/gui/text/windows/qwindowsfontdatabase.cpp +++ b/src/gui/text/windows/qwindowsfontdatabase.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -499,7 +500,7 @@ namespace { {} QString populatedFontFamily; - QSet foundFontAndStyles; + QDuplicateTracker foundFontAndStyles; QWindowsFontDatabase *windowsFontDatabase; }; } @@ -642,10 +643,8 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t signature = &reinterpret_cast(textmetric)->ntmFontSig; // We get a callback for each script-type supported, but we register them all // at once using the signature, so we only need one call to addFontToDatabase(). - FontAndStyle fontAndStyle = {familyName, styleName}; - if (sfp->foundFontAndStyles.contains(fontAndStyle)) + if (sfp->foundFontAndStyles.hasSeen({familyName, styleName})) return 1; - sfp->foundFontAndStyles.insert(fontAndStyle); } addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type, sfp); -- cgit v1.2.3