[Libreoffice-commits] core.git: sax/source
Noel Grandin
noel.grandin at collabora.co.uk
Wed Jul 11 11:10:41 UTC 2018
sax/source/fastparser/fastparser.cxx | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit bd394492c165d27c96a44495d9ca694a242acb8f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jul 11 09:58:30 2018 +0200
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 at collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
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)
{
More information about the Libreoffice-commits
mailing list