Skip to content

Commit

Permalink
Fix GCC warning on Release build in Emoji::Init.
Browse files Browse the repository at this point in the history
Also use initializer_list instead of recursion in Emoji::ComputeId.
  • Loading branch information
john-preston committed Mar 23, 2017
1 parent 731e53b commit 47044ab
Show file tree
Hide file tree
Showing 3 changed files with 2,181 additions and 2,191 deletions.
19 changes: 7 additions & 12 deletions Telegram/SourceFiles/codegen/emoji/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,14 @@ EmojiPtr ByIndex(int index) {\n\
return (index >= 0 && index < Items.size()) ? &Items[index] : nullptr;\n\
}\n\
\n\
inline void AppendChars(QString &result) {\n\
}\n\
\n\
template <typename ...Args>\n\
inline void AppendChars(QString &result, ushort unicode, Args... args) {\n\
result.append(QChar(unicode));\n\
AppendChars(result, args...);\n\
}\n\
\n\
template <typename ...Args>\n\
inline QString ComputeId(Args... args) {\n\
auto utf16 = { args... };\n\
auto result = QString();\n\
result.reserve(sizeof...(args));\n\
AppendChars(result, args...);\n\
result.reserve(utf16.size());\n\
for (auto ch : utf16) {\n\
result.append(QChar(ch));\n\
}\n\
return result;\n\
}\n";
if (!writeFindReplace()) {
Expand Down Expand Up @@ -342,6 +336,7 @@ bool Generator::writeInitCode() {
source_->stream() << "\
\n\
void Init() {\n\
auto tag = One::CreationTag();\n\
auto scaleForEmoji = cRetina() ? dbisTwo : cScale();\n\
\n\
switch (scaleForEmoji) {\n";
Expand All @@ -363,7 +358,7 @@ void Init() {\n\
auto coloredCount = 0;
for (auto &item : data_.list) {
source_->stream() << "\
Items.emplace_back(" << computeId(item.id) << ", " << column << ", " << row << ", " << (item.postfixed ? "true" : "false") << ", " << (item.variated ? "true" : "false") << ", " << (item.colored ? "&Items[" + QString::number(variated) + "]" : "nullptr") << ", One::CreationTag());\n";
Items.emplace_back(" << computeId(item.id) << ", " << column << ", " << row << ", " << (item.postfixed ? "true" : "false") << ", " << (item.variated ? "true" : "false") << ", " << (item.colored ? "&Items[" + QString::number(variated) + "]" : "nullptr") << ", tag);\n";
if (coloredCount > 0 && (item.variated || !item.colored)) {
if (!colorsCount_) {
colorsCount_ = coloredCount;
Expand Down
Loading

0 comments on commit 47044ab

Please sign in to comment.