[Libreoffice-commits] .: writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Nov 23 10:59:30 PST 2012
writerfilter/source/rtftok/rtftokenizer.cxx | 11 +++++++++--
writerfilter/source/rtftok/rtftokenizer.hxx | 5 +++--
2 files changed, 12 insertions(+), 4 deletions(-)
New commits:
commit 292422a7dc4fb4b8b3d9d9b90107fd829ff18100
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Nov 23 19:52:38 2012 +0100
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
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index b2fe78c..6620e74 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 94cbe40..c717faa 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;
More information about the Libreoffice-commits
mailing list