From 37481a4f6fa9e8b05f0946771c3a15dc3d9fd797 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 3 Dec 2017 21:53:10 +0300 Subject: SpellChecker: code cleaning --- plugins/SpellChecker/src/dictionary.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'plugins/SpellChecker') diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp index e12c7d7d47..92f74af3b2 100644 --- a/plugins/SpellChecker/src/dictionary.cpp +++ b/plugins/SpellChecker/src/dictionary.cpp @@ -428,12 +428,12 @@ protected: return ret; } - wchar_t* fromHunspellAndFree(std::string hunspellWord) + wchar_t* fromHunspellAndFree(const char *hunspellWord) { - if (hunspellWord.c_str() == nullptr) + if (hunspellWord == nullptr) return nullptr; - wchar_t *ret = fromHunspell(hunspellWord.c_str()); + wchar_t *ret = fromHunspell(hunspellWord); return ret; } @@ -460,16 +460,15 @@ public: virtual ~HunspellDictionary() { - if (hunspell != nullptr) - delete hunspell; + delete hunspell; if (wordChars != nullptr) free(wordChars); } wchar_t * merge(wchar_t * s1, wchar_t *s2) { - int len1 = (s1 == nullptr ? 0 : mir_wstrlen(s1)); - int len2 = (s2 == nullptr ? 0 : mir_wstrlen(s2)); + int len1 = mir_wstrlen(s1); + int len2 = mir_wstrlen(s2); wchar_t *ret; if (len1 > 0 && len2 > 0) { @@ -549,7 +548,7 @@ public: hwordchars = fromHunspell(hunspell->get_wordchars()); } - wchar_t *casechars = fromHunspellAndFree(get_casechars(dic_enc)); + wchar_t *casechars = fromHunspellAndFree(get_casechars(dic_enc).c_str()); wchar_t *try_string = fromHunspellAndFree(hunspell->get_try_string()); wordChars = merge(merge(casechars, hwordchars), try_string); -- cgit v1.2.3