Speedup provider compilation

This commit is contained in:
Nicolas Werner 2022-06-16 00:49:12 +02:00
parent 81d4285580
commit f8e6c9c53c
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
4 changed files with 5 additions and 8 deletions

View file

@ -14,7 +14,7 @@ class Emoji(object):
def generate_qml_list(**kwargs): def generate_qml_list(**kwargs):
tmpl = Template(''' tmpl = Template('''
const QVector<Emoji> emoji::Provider::emoji = { const std::array<Emoji, {{ sum([len(c[1]) for c in kwargs.items()]) }}> emoji::Provider::emoji = {
{%- for c in kwargs.items() %} {%- for c in kwargs.items() %}
// {{ c[0].capitalize() }} // {{ c[0].capitalize() }}
{%- for e in c[1] %} {%- for e in c[1] %}

View file

@ -45,7 +45,7 @@ EmojiModel::roleNames() const
int int
EmojiModel::rowCount(const QModelIndex &parent) const EmojiModel::rowCount(const QModelIndex &parent) const
{ {
return parent == QModelIndex() ? Provider::emoji.count() : 0; return parent == QModelIndex() ? Provider::emoji.size() : 0;
} }
QVariant QVariant

View file

@ -7,7 +7,7 @@
using namespace emoji; using namespace emoji;
const QVector<Emoji> emoji::Provider::emoji = { const std::array<Emoji, 3650> emoji::Provider::emoji = {
// People // People
Emoji{QStringLiteral(u"\U0001F600"), Emoji{QStringLiteral(u"\U0001F600"),
QStringLiteral(u"grinning"), QStringLiteral(u"grinning"),

View file

@ -7,10 +7,7 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include <QSet> #include <array>
#include <QString>
#include <QVector>
#include <vector>
namespace emoji { namespace emoji {
Q_NAMESPACE Q_NAMESPACE
@ -49,7 +46,7 @@ class Provider
{ {
public: public:
// all emoji for QML purposes // all emoji for QML purposes
static const QVector<Emoji> emoji; static const std::array<Emoji, 3650> emoji;
}; };
} // namespace emoji } // namespace emoji