summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-11-23 19:52:38 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-11-23 19:57:30 +0100
commit292422a7dc4fb4b8b3d9d9b90107fd829ff18100 (patch)
treebe33179399bc44942cb2d305f49f5e0439b8dd7e
parent1474acef8a77926ae07d109256fecd2392b37510 (diff)
writerfilter: sort RTF keywords only once in RTFTokenizer
This pushes down import time of http://people.freedesktop.org/~vmiklos/2012/footnote-10k.rtf.xz from 10sec to 5sec on my machine. Change-Id: I39b7e4ea59fb5c05c1d3940920950ebc47adb48b
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.cxx11
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.hxx5
2 files changed, 12 insertions, 4 deletions
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index b2fe78cab66b..6620e742da6f 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -42,16 +42,23 @@ using rtl::OUStringToOString;
namespace writerfilter {
namespace rtftok {
+std::vector<RTFSymbol> RTFTokenizer::m_aRTFControlWords;
+bool RTFTokenizer::m_bControlWordsSorted;
+
RTFTokenizer::RTFTokenizer(RTFDocumentImpl& rImport, SvStream* pInStream, uno::Reference<task::XStatusIndicator> const& xStatusIndicator)
: m_rImport(rImport),
m_pInStream(pInStream),
m_xStatusIndicator(xStatusIndicator),
- m_aRTFControlWords(std::vector<RTFSymbol>(aRTFControlWords, aRTFControlWords + nRTFControlWords)),
m_nGroup(0),
m_nLineNumber(0),
m_nLineStartPos(0)
{
- std::sort(m_aRTFControlWords.begin(), m_aRTFControlWords.end());
+ if (!RTFTokenizer::m_bControlWordsSorted)
+ {
+ RTFTokenizer::m_bControlWordsSorted = true;
+ m_aRTFControlWords = std::vector<RTFSymbol>(aRTFControlWords, aRTFControlWords + nRTFControlWords);
+ std::sort(m_aRTFControlWords.begin(), m_aRTFControlWords.end());
+ }
}
RTFTokenizer::~RTFTokenizer()
diff --git a/writerfilter/source/rtftok/rtftokenizer.hxx b/writerfilter/source/rtftok/rtftokenizer.hxx
index 94cbe402e857..c717faab45eb 100644
--- a/writerfilter/source/rtftok/rtftokenizer.hxx
+++ b/writerfilter/source/rtftok/rtftokenizer.hxx
@@ -58,8 +58,9 @@ namespace writerfilter {
RTFDocumentImpl& m_rImport;
SvStream* m_pInStream;
uno::Reference<task::XStatusIndicator> const& m_xStatusIndicator;
- // This is the same as m_aRTFControlWords, but sorted
- std::vector<RTFSymbol> m_aRTFControlWords;
+ // This is the same as aRTFControlWords, but sorted
+ static std::vector<RTFSymbol> m_aRTFControlWords;
+ static bool m_bControlWordsSorted;
/// Same as the size of the importer's states, except that this can be negative for invalid input.
int m_nGroup;
sal_Int32 m_nLineNumber;