Speedup provider compilation

pull/1100/head
Nicolas Werner 2 years ago
parent 81d4285580
commit f8e6c9c53c
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 2
      scripts/emoji_codegen.py
  2. 2
      src/emoji/EmojiModel.cpp
  3. 2
      src/emoji/Provider.cpp
  4. 7
      src/emoji/Provider.h

@ -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] %}

@ -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

@ -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"),

@ -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

Loading…
Cancel
Save