Loading extensions/spellcheck/src/mozPersonalDictionary.cpp +9 −20 Original line number Diff line number Diff line Loading @@ -301,7 +301,7 @@ void mozPersonalDictionary::SyncLoadInternal() { if ((NS_OK != convStream->Read(&c, 1, &nRead)) || (nRead != 1)) done = true; } mDictionaryTable.PutEntry(word); mDictionaryTable.Insert(word); } } while (!done); } Loading Loading @@ -348,15 +348,8 @@ NS_IMETHODIMP mozPersonalDictionary::Save() { return res; } nsTArray<nsString> array; nsString* elems = array.AppendElements(mDictionaryTable.Count()); for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) { elems->Assign(iter.Get()->GetKey()); elems++; } nsCOMPtr<nsIRunnable> runnable = new mozPersonalDictionarySave(this, theFile, std::move(array)); nsCOMPtr<nsIRunnable> runnable = new mozPersonalDictionarySave( this, theFile, mozilla::ToTArray<nsTArray<nsString>>(mDictionaryTable)); res = target->Dispatch(runnable, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(res))) { return res; Loading @@ -370,12 +363,8 @@ NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator** aWords) { WaitForLoad(); nsTArray<nsString>* array = new nsTArray<nsString>(); nsString* elems = array->AppendElements(mDictionaryTable.Count()); for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) { elems->Assign(iter.Get()->GetKey()); elems++; } nsTArray<nsString>* array = new nsTArray<nsString>( mozilla::ToTArray<nsTArray<nsString>>(mDictionaryTable)); array->Sort(); Loading @@ -388,7 +377,7 @@ mozPersonalDictionary::Check(const nsAString& aWord, bool* aResult) { WaitForLoad(); *aResult = (mDictionaryTable.GetEntry(aWord) || mIgnoreTable.GetEntry(aWord)); *aResult = (mDictionaryTable.Contains(aWord) || mIgnoreTable.Contains(aWord)); return NS_OK; } Loading @@ -397,7 +386,7 @@ mozPersonalDictionary::AddWord(const nsAString& aWord) { nsresult res; WaitForLoad(); mDictionaryTable.PutEntry(aWord); mDictionaryTable.Insert(aWord); res = Save(); return res; } Loading @@ -407,7 +396,7 @@ mozPersonalDictionary::RemoveWord(const nsAString& aWord) { nsresult res; WaitForLoad(); mDictionaryTable.RemoveEntry(aWord); mDictionaryTable.Remove(aWord); res = Save(); return res; } Loading @@ -415,7 +404,7 @@ mozPersonalDictionary::RemoveWord(const nsAString& aWord) { NS_IMETHODIMP mozPersonalDictionary::IgnoreWord(const nsAString& aWord) { // avoid adding duplicate words to the ignore list if (!mIgnoreTable.GetEntry(aWord)) mIgnoreTable.PutEntry(aWord); mIgnoreTable.EnsureInserted(aWord); return NS_OK; } Loading extensions/spellcheck/src/mozPersonalDictionary.h +3 −3 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ #include "mozIPersonalDictionary.h" #include "nsIObserver.h" #include "nsWeakReference.h" #include "nsTHashtable.h" #include "nsTHashSet.h" #include "nsCRT.h" #include "nsCycleCollectionParticipant.h" #include "nsHashKeys.h" Loading Loading @@ -53,8 +53,8 @@ class mozPersonalDictionary final : public mozIPersonalDictionary, nsCOMPtr<nsIFile> mFile; mozilla::Monitor mMonitor; mozilla::Monitor mMonitorSave; nsTHashtable<nsStringHashKey> mDictionaryTable; nsTHashtable<nsStringHashKey> mIgnoreTable; nsTHashSet<nsString> mDictionaryTable; nsTHashSet<nsString> mIgnoreTable; private: /* wait for the asynchronous load of the dictionary to be completed */ Loading extensions/spellcheck/src/mozSpellChecker.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -320,7 +320,7 @@ nsresult mozSpellChecker::GetDictionaryList( nsresult rv; // For catching duplicates nsTHashtable<nsCStringHashKey> dictionaries; nsTHashSet<nsCString> dictionaries; nsCOMArray<mozISpellCheckingEngine> spellCheckingEngines; rv = GetEngineList(&spellCheckingEngines); Loading @@ -334,9 +334,8 @@ nsresult mozSpellChecker::GetDictionaryList( for (auto& dictName : dictNames) { // Skip duplicate dictionaries. Only take the first one // for each name. if (dictionaries.Contains(dictName)) continue; if (!dictionaries.EnsureInserted(dictName)) continue; dictionaries.PutEntry(dictName); aDictionaryList->AppendElement(dictName); } } Loading Loading
extensions/spellcheck/src/mozPersonalDictionary.cpp +9 −20 Original line number Diff line number Diff line Loading @@ -301,7 +301,7 @@ void mozPersonalDictionary::SyncLoadInternal() { if ((NS_OK != convStream->Read(&c, 1, &nRead)) || (nRead != 1)) done = true; } mDictionaryTable.PutEntry(word); mDictionaryTable.Insert(word); } } while (!done); } Loading Loading @@ -348,15 +348,8 @@ NS_IMETHODIMP mozPersonalDictionary::Save() { return res; } nsTArray<nsString> array; nsString* elems = array.AppendElements(mDictionaryTable.Count()); for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) { elems->Assign(iter.Get()->GetKey()); elems++; } nsCOMPtr<nsIRunnable> runnable = new mozPersonalDictionarySave(this, theFile, std::move(array)); nsCOMPtr<nsIRunnable> runnable = new mozPersonalDictionarySave( this, theFile, mozilla::ToTArray<nsTArray<nsString>>(mDictionaryTable)); res = target->Dispatch(runnable, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(res))) { return res; Loading @@ -370,12 +363,8 @@ NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator** aWords) { WaitForLoad(); nsTArray<nsString>* array = new nsTArray<nsString>(); nsString* elems = array->AppendElements(mDictionaryTable.Count()); for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) { elems->Assign(iter.Get()->GetKey()); elems++; } nsTArray<nsString>* array = new nsTArray<nsString>( mozilla::ToTArray<nsTArray<nsString>>(mDictionaryTable)); array->Sort(); Loading @@ -388,7 +377,7 @@ mozPersonalDictionary::Check(const nsAString& aWord, bool* aResult) { WaitForLoad(); *aResult = (mDictionaryTable.GetEntry(aWord) || mIgnoreTable.GetEntry(aWord)); *aResult = (mDictionaryTable.Contains(aWord) || mIgnoreTable.Contains(aWord)); return NS_OK; } Loading @@ -397,7 +386,7 @@ mozPersonalDictionary::AddWord(const nsAString& aWord) { nsresult res; WaitForLoad(); mDictionaryTable.PutEntry(aWord); mDictionaryTable.Insert(aWord); res = Save(); return res; } Loading @@ -407,7 +396,7 @@ mozPersonalDictionary::RemoveWord(const nsAString& aWord) { nsresult res; WaitForLoad(); mDictionaryTable.RemoveEntry(aWord); mDictionaryTable.Remove(aWord); res = Save(); return res; } Loading @@ -415,7 +404,7 @@ mozPersonalDictionary::RemoveWord(const nsAString& aWord) { NS_IMETHODIMP mozPersonalDictionary::IgnoreWord(const nsAString& aWord) { // avoid adding duplicate words to the ignore list if (!mIgnoreTable.GetEntry(aWord)) mIgnoreTable.PutEntry(aWord); mIgnoreTable.EnsureInserted(aWord); return NS_OK; } Loading
extensions/spellcheck/src/mozPersonalDictionary.h +3 −3 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ #include "mozIPersonalDictionary.h" #include "nsIObserver.h" #include "nsWeakReference.h" #include "nsTHashtable.h" #include "nsTHashSet.h" #include "nsCRT.h" #include "nsCycleCollectionParticipant.h" #include "nsHashKeys.h" Loading Loading @@ -53,8 +53,8 @@ class mozPersonalDictionary final : public mozIPersonalDictionary, nsCOMPtr<nsIFile> mFile; mozilla::Monitor mMonitor; mozilla::Monitor mMonitorSave; nsTHashtable<nsStringHashKey> mDictionaryTable; nsTHashtable<nsStringHashKey> mIgnoreTable; nsTHashSet<nsString> mDictionaryTable; nsTHashSet<nsString> mIgnoreTable; private: /* wait for the asynchronous load of the dictionary to be completed */ Loading
extensions/spellcheck/src/mozSpellChecker.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -320,7 +320,7 @@ nsresult mozSpellChecker::GetDictionaryList( nsresult rv; // For catching duplicates nsTHashtable<nsCStringHashKey> dictionaries; nsTHashSet<nsCString> dictionaries; nsCOMArray<mozISpellCheckingEngine> spellCheckingEngines; rv = GetEngineList(&spellCheckingEngines); Loading @@ -334,9 +334,8 @@ nsresult mozSpellChecker::GetDictionaryList( for (auto& dictName : dictNames) { // Skip duplicate dictionaries. Only take the first one // for each name. if (dictionaries.Contains(dictName)) continue; if (!dictionaries.EnsureInserted(dictName)) continue; dictionaries.PutEntry(dictName); aDictionaryList->AppendElement(dictName); } } Loading