void SpellCheckWorker::findSuggestions(const QString &word) { bool needsCorrections = false; m_SuggestionsLock.lockForRead(); needsCorrections = !m_Suggestions.contains(word); m_SuggestionsLock.unlock(); if (needsCorrections) { QStringList suggestions = suggestCorrections(word); m_SuggestionsLock.lockForWrite(); m_Suggestions.insert(word, suggestions); m_SuggestionsLock.unlock(); } }
void SpellCheckWorker::findSuggestions(const QString &word) { LOG_VERBOSE << word; bool needsCorrections = false; QStringList suggestions; m_SuggestionsLock.lockForRead(); needsCorrections = !m_Suggestions.tryGet(word, suggestions); m_SuggestionsLock.unlock(); if (needsCorrections) { suggestions = suggestCorrections(word); m_SuggestionsLock.lockForWrite(); { m_Suggestions.put(word, suggestions); } m_SuggestionsLock.unlock(); } }