From c0aca7e4c803637c4a6f98e141d397ca9f2eac01 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sat, 28 Dec 2024 22:40:32 +0800 Subject: [PATCH 1/2] opt: icon generate refactor --- src/common/dictionary_icon_name.cc | 10 ++++------ src/common/dictionary_icon_name.hh | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/common/dictionary_icon_name.cc b/src/common/dictionary_icon_name.cc index add0fc7c4..66e4703fb 100644 --- a/src/common/dictionary_icon_name.cc +++ b/src/common/dictionary_icon_name.cc @@ -16,17 +16,15 @@ QString Icons::DictionaryIconName::getIconName( const QString & dictionaryName ) //get the first character of the dictionary name QString name = dictionaryName.at( 0 ).toUpper(); auto it1 = _iconDictionaryNames.contains( name ); - std::vector< QString > vector = {}; if ( it1 ) { - vector = _iconDictionaryNames.value( name ); - vector.emplace_back( dictionaryName ); + auto vector = _iconDictionaryNames.value( name ); + _iconDictionaryNames.insert( name, vector++ ); } else { - vector.emplace_back( dictionaryName ); - _iconDictionaryNames.insert( name, vector ); + _iconDictionaryNames.insert( name, 1 ); } - name = name + QString::number( vector.size() ); + name = name + QString::number( _iconDictionaryNames.value( name ) ); _dictionaryIconNames.insert( dictionaryName, name ); return name; } \ No newline at end of file diff --git a/src/common/dictionary_icon_name.hh b/src/common/dictionary_icon_name.hh index 6906044b0..0f022ef6e 100644 --- a/src/common/dictionary_icon_name.hh +++ b/src/common/dictionary_icon_name.hh @@ -12,7 +12,7 @@ namespace Icons { class DictionaryIconName { //map icon name to dictionary names; - QMap< QString, std::vector< QString > > _iconDictionaryNames; + QMap< QString, int > _iconDictionaryNames; //map dictionary name to icon name; QMap< QString, QString > _dictionaryIconNames; From d6c7d11a3f847fc09585f5cc65b55b5635032180 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sat, 28 Dec 2024 22:43:41 +0800 Subject: [PATCH 2/2] 1 --- src/common/dictionary_icon_name.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/dictionary_icon_name.cc b/src/common/dictionary_icon_name.cc index 66e4703fb..d081f7deb 100644 --- a/src/common/dictionary_icon_name.cc +++ b/src/common/dictionary_icon_name.cc @@ -18,7 +18,8 @@ QString Icons::DictionaryIconName::getIconName( const QString & dictionaryName ) auto it1 = _iconDictionaryNames.contains( name ); if ( it1 ) { auto vector = _iconDictionaryNames.value( name ); - _iconDictionaryNames.insert( name, vector++ ); + vector++; + _iconDictionaryNames.insert( name, vector ); } else { _iconDictionaryNames.insert( name, 1 );