summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-11 09:58:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-11 13:10:18 +0200
commitbd394492c165d27c96a44495d9ca694a242acb8f (patch)
tree06f9269c0d234957864abc5588e186952f80b9cd
parent00850e3fa71cc9ebeacad65f54a98b9a79a8b183 (diff)
tdf#79878 perf loading docx file, improve threading heuristic
this gives another 2% perf Change-Id: Ia2983339f3f11daef37c48044904c8037a7a0bf6 Reviewed-on: https://gerrit.libreoffice.org/57265 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sax/source/fastparser/fastparser.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 72e42c1d0247..83b36d122f42 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -22,6 +22,7 @@
#include <xml2utf.hxx>
#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -780,8 +781,13 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
rEntity.mxDocumentHandler->startDocument();
}
- rEntity.mbEnableThreads = rEntity.maStructSource.aInputStream->available() > 10000
- && !getenv("SAX_DISABLE_THREADS");
+ if (!getenv("SAX_DISABLE_THREADS"))
+ {
+ Reference<css::io::XSeekable> xSeekable(rEntity.maStructSource.aInputStream, UNO_QUERY);
+ // available() is not __really__ relevant here, but leave it in as a heuristic for non-seekable streams
+ rEntity.mbEnableThreads = (xSeekable.is() && xSeekable->getLength() > 10000)
+ || (rEntity.maStructSource.aInputStream->available() > 10000);
+ }
if (rEntity.mbEnableThreads)
{