From 60adbd56db26f48a8fca8d057d9d27af8d69cd8d Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Tue, 5 Jan 2021 20:37:54 +0100 Subject: Refactoring: modernize emoji class --- src/emoji.cpp | 9 +++------ src/emoji.h | 6 ++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/emoji.cpp b/src/emoji.cpp index 311f748..a8a2bb8 100644 --- a/src/emoji.cpp +++ b/src/emoji.cpp @@ -1521,18 +1521,15 @@ EmojiEntityMapper *EmojiEntityMapper::s_instance = 0; EmojiEntityMapper::EmojiEntityMapper() { - m_name2symGh = new QDict(1009); - m_name2symGh->setAutoDelete(TRUE); // 2 loops to be able to give precedence to the unicodeName (CLDR) for (int i = 0; i < g_numEmojiEntities; i++) { - m_name2symGh->insert(g_emojiEntities[i].name, new int(i)); + m_name2symGh.insert(std::make_pair(g_emojiEntities[i].name, i)); } } EmojiEntityMapper::~EmojiEntityMapper() { - delete m_name2symGh; } /** Returns the one and only instance of the Emoji entity mapper */ @@ -1560,8 +1557,8 @@ void EmojiEntityMapper::deleteInstance() */ int EmojiEntityMapper::symbol2index(const QCString &symName) const { - int *val = m_name2symGh->find(symName); - return val ? *val : -1; + auto it = m_name2symGh.find(symName.str()); + return it!=m_name2symGh.end() ? it->second : -1; } /*! diff --git a/src/emoji.h b/src/emoji.h index f24a2c0..b27b761 100644 --- a/src/emoji.h +++ b/src/emoji.h @@ -15,7 +15,9 @@ #ifndef EMOJIENTITY_H #define EMOJIENTITY_H -#include +#include +#include + #include class FTextStream; @@ -35,7 +37,7 @@ class EmojiEntityMapper EmojiEntityMapper(); ~EmojiEntityMapper(); static EmojiEntityMapper *s_instance; - QDict *m_name2symGh; + std::map m_name2symGh; }; #endif -- cgit v0.12