summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-06-04 17:39:20 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-07-30 15:59:55 +0200
commit09fba5cf3657c19c38e897a11a015d45b4328ae3 (patch)
tree27e5fe5b1ff5178432e15f1aa414ceb25e031df2 /src
parent0edda211f9a333b322ab5b6d0156271f4d460ece (diff)
QWindowsFontDatabase: port local QSets to QDuplicateTracker
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 <qt_ci_bot@qt-project.org> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/windows/qwindowsfontdatabase.cpp7
-rw-r--r--src/gui/text/windows/qwindowsfontdatabase_ft.cpp10
2 files changed, 8 insertions, 9 deletions
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 <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QtEndian>
+#include <QtCore/private/qduplicatetracker_p.h>
#include <QtCore/private/qsystemlibrary_p.h>
#include <QtCore/private/qwinregistry_p.h>
@@ -499,7 +500,7 @@ namespace {
{}
QString populatedFontFamily;
- QSet<FontAndStyle> foundFontAndStyles;
+ QDuplicateTracker<FontAndStyle> foundFontAndStyles;
QWindowsFontDatabase *windowsFontDatabase;
};
}
@@ -642,10 +643,8 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(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);
diff --git a/src/gui/text/windows/qwindowsfontdatabase_ft.cpp b/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
index e2c8d3455d..b149701de5 100644
--- a/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
@@ -51,6 +51,8 @@
#if QT_CONFIG(regularexpression)
#include <QtCore/QRegularExpression>
#endif
+#include <QtCore/private/qduplicatetracker_p.h>
+
#include <QtGui/QGuiApplication>
#include <QtGui/QFontDatabase>
@@ -318,11 +320,9 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(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().
- QSet<FontAndStyle> *foundFontAndStyles = reinterpret_cast<QSet<FontAndStyle> *>(lparam);
- FontAndStyle fontAndStyle = {faceName, styleName};
- if (foundFontAndStyles->contains(fontAndStyle))
+ auto foundFontAndStyles = reinterpret_cast<QDuplicateTracker<FontAndStyle> *>(lparam);
+ if (foundFontAndStyles->hasSeen({faceName, styleName}))
return 1;
- foundFontAndStyles->insert(fontAndStyle);
}
addFontToDatabase(faceName, styleName, fullName, *logFont, textmetric, signature, type);
@@ -352,7 +352,7 @@ void QWindowsFontDatabaseFT::populateFamily(const QString &familyName)
lf.lfFaceName[familyName.size()] = 0;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfPitchAndFamily = 0;
- QSet<FontAndStyle> foundFontAndStyles;
+ QDuplicateTracker<FontAndStyle> foundFontAndStyles;
EnumFontFamiliesEx(dummy, &lf, storeFont, reinterpret_cast<intptr_t>(&foundFontAndStyles), 0);
ReleaseDC(0, dummy);
}