diff options
author | George Hazan <ghazan@miranda.im> | 2018-01-26 22:31:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-01-26 22:31:27 +0300 |
commit | 391980ce1e890445542441eeb5d9f9cc18ae1baf (patch) | |
tree | ee1b165175dcdaeeaabd2ddb822542e648663a90 /plugins/SpellChecker | |
parent | bf8ad124d03b4fd059318d9ba8889b11faaf5b53 (diff) |
code optimization
Diffstat (limited to 'plugins/SpellChecker')
-rw-r--r-- | plugins/SpellChecker/src/dictionary.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp index 4fd5123aa5..03fa58e5fb 100644 --- a/plugins/SpellChecker/src/dictionary.cpp +++ b/plugins/SpellChecker/src/dictionary.cpp @@ -537,10 +537,10 @@ public: } else { - for (int i = 0; i < _countof(codepages); i++) { - if (_strcmpi(codepages[i].name, dic_enc) == 0) { - if (IsValidCodePage(codepages[i].codepage)) - codePage = codepages[i].codepage; + for (auto &it : codepages) { + if (_strcmpi(it.name, dic_enc) == 0) { + if (IsValidCodePage(it.codepage)) + codePage = it.codepage; break; } } @@ -786,20 +786,18 @@ void GetDictsInfo(LIST<Dictionary> &dicts) } if (dict->localized_name[0] == '\0') { - for (size_t j = 0; j < _countof(aditionalLanguages); j++) { - if (!mir_wstrcmp(aditionalLanguages[j].language, dict->language)) { - mir_wstrncpy(dict->localized_name, TranslateW(aditionalLanguages[j].localized_name), _countof(dict->localized_name)); + for (auto &it : aditionalLanguages) { + if (!mir_wstrcmp(it.language, dict->language)) { + mir_wstrncpy(dict->localized_name, TranslateW(it.localized_name), _countof(dict->localized_name)); break; } } } - if (dict->localized_name[0] != '\0') { + if (dict->localized_name[0] != '\0') mir_snwprintf(dict->full_name, L"%s [%s]", dict->localized_name, dict->language); - } - else { + else mir_wstrncpy(dict->full_name, dict->language, _countof(dict->full_name)); - } } } } @@ -865,9 +863,9 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use if (opts.use_other_apps_dicts) { // Get other apps dicts - for (int i = 0; i < _countof(otherHunspellApps); i++) { + for (auto &it : otherHunspellApps) { wchar_t key[1024]; - mir_snwprintf(key, APPPATH, otherHunspellApps[i].key); + mir_snwprintf(key, APPPATH, it.key); HKEY hKey = nullptr; LONG lResult = 0; @@ -892,7 +890,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use key[cchValue] = 0; wchar_t *pos; if (pos = wcsrchr(key, '\\')) { - if (!mir_wstrcmpi(&pos[1], otherHunspellApps[i].key)) { + if (!mir_wstrcmpi(&pos[1], it.key)) { pos[0] = 0; lResult = ERROR_SUCCESS; break; @@ -907,7 +905,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use wchar_t folder[1024]; mir_snwprintf(folder, L"%s\\Dictionaries", key); - GetHunspellDictionariesFromFolder(languages, folder, user_path, otherHunspellApps[i].name); + GetHunspellDictionariesFromFolder(languages, folder, user_path, it.name); } } } |