summaryrefslogtreecommitdiff
path: root/editeng/inc
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-12-10 20:41:38 +0000
committerMichael Meeks <michael.meeks@suse.com>2012-12-10 20:43:50 +0000
commite7e4d6778661d039d6ee9cba1da1a22cea542f3e (patch)
tree796a9792832dde8dd7b880b28eb7ba66595481c7 /editeng/inc
parentcccb0bb123ac89a0a4cb8ba335ce5cb64cdc87cf (diff)
fdo#55570 - use a hash instead of set initially until sorting needed
This rather substantially accelerates the first use of autocorrection. Interestingly, it also appears to accelerate the sorting of the items; potentially inserting sorted items into a set is a pathological balancing case, that is avoided by the hash algorithm's randomness.
Diffstat (limited to 'editeng/inc')
-rw-r--r--editeng/inc/editeng/svxacorr.hxx37
1 files changed, 25 insertions, 12 deletions
diff --git a/editeng/inc/editeng/svxacorr.hxx b/editeng/inc/editeng/svxacorr.hxx
index 1aec424afa8a..79f8e9df7778 100644
--- a/editeng/inc/editeng/svxacorr.hxx
+++ b/editeng/inc/editeng/svxacorr.hxx
@@ -33,6 +33,7 @@
#include <map>
#include <set>
+#include <boost/unordered_map.hpp>
#include <boost/ptr_container/ptr_map.hpp>
class CharClass;
@@ -132,7 +133,7 @@ public:
const String& GetShort() const { return sShort; }
const String& GetLong() const { return sLong; }
- sal_Bool IsTextOnly() const { return bIsTxtOnly; }
+ sal_Bool IsTextOnly() const { return bIsTxtOnly; }
};
struct CompareSvxAutocorrWordList
@@ -140,20 +141,32 @@ struct CompareSvxAutocorrWordList
bool operator()( SvxAutocorrWord* const& lhs, SvxAutocorrWord* const& rhs ) const;
};
-typedef std::set<SvxAutocorrWord*, CompareSvxAutocorrWordList> SvxAutocorrWordList_Base;
-class EDITENG_DLLPUBLIC SvxAutocorrWordList : SvxAutocorrWordList_Base
+typedef std::set<SvxAutocorrWord*, CompareSvxAutocorrWordList> SvxAutocorrWordList_Set;
+typedef ::boost::unordered_map< ::rtl::OUString, SvxAutocorrWord *,
+ ::rtl::OUStringHash > SvxAutocorrWordList_Hash;
+
+class EDITENG_DLLPUBLIC SvxAutocorrWordList
{
+ // only one of these contains the data
+ mutable SvxAutocorrWordList_Set maSet;
+ mutable SvxAutocorrWordList_Hash maHash; // key is 'Short'
+
+ bool WordMatches(const SvxAutocorrWord *pFnd,
+ const String &rTxt,
+ xub_StrLen &rStt,
+ xub_StrLen nEndPos) const;
public:
- typedef SvxAutocorrWordList_Base::iterator iterator;
+ // free any objects still in the set
+ ~SvxAutocorrWordList();
+ void DeleteAndDestroyAll();
+ bool Insert(SvxAutocorrWord *pWord);
+ SvxAutocorrWord* FindAndRemove(SvxAutocorrWord *pWord);
+ void LoadEntry(String sWrong, String sRight, sal_Bool bOnlyTxt);
+ bool empty() const;
+
typedef std::vector<SvxAutocorrWord *> Content;
- // free any objects still in the set
- ~SvxAutocorrWordList();
- void DeleteAndDestroyAll();
- bool Insert(SvxAutocorrWord *pWord);
- SvxAutocorrWord *FindAndRemove(SvxAutocorrWord *pWord);
- void LoadEntry(String sWrong, String sRight, sal_Bool bOnlyTxt);
- bool empty() const;
- Content getSortedContent() const;
+ Content getSortedContent() const;
+
const SvxAutocorrWord* SearchWordsInList(const String& rTxt, xub_StrLen& rStt, xub_StrLen nEndPos) const;
};