summaryrefslogtreecommitdiff
path: root/unotools/source/ucbhelper/xtempfile.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2021-06-20 18:51:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-06-21 18:37:04 +0200
commit218f36dd614cf828e949f605faaf6a6fd615da26 (patch)
tree840e81055a02498b5cbc46b81ca88de318f97005 /unotools/source/ucbhelper/xtempfile.cxx
parentee405fb2ef36337851801f1bd34411c606d55988 (diff)
tdf#135316 remove OTempFileService pessimisation
Closing the temp file when we read to the end, and then opening it again later actually is quite expensive, just leave it open. This takes my load time from 22s to 19s Also clean up the unit-test that failed, so that I can get a useful stack trace out of it when something fails, specifically (*) throw an exception when something goes wrong, instead of just writing a message to stdout (*) don't catch exceptions and write useless messages - just let the exception flow up to the JUnit handler, which will log a nice stacktrace with line numbers. Change-Id: If55c997f91eea4e703e92c632961d68b3453076d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117517 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools/source/ucbhelper/xtempfile.cxx')
-rw-r--r--unotools/source/ucbhelper/xtempfile.cxx42
1 files changed, 0 insertions, 42 deletions
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index 7eb7e3677e18..ae8140526441 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -32,9 +32,6 @@ OTempFileService::OTempFileService(css::uno::Reference< css::uno::XComponentCont
, mbRemoveFile( true )
, mbInClosed( false )
, mbOutClosed( false )
-, mnCachedPos( 0 )
-, mbHasCachedPos( false )
-
{
mpTempFile.reset(new utl::TempFile());
mpTempFile->EnableKillingFile();
@@ -127,18 +124,6 @@ sal_Int32 SAL_CALL OTempFileService::readBytes( css::uno::Sequence< sal_Int8 >&
if (nRead < o3tl::make_unsigned(aData.getLength()))
aData.realloc( nRead );
- if ( sal::static_int_cast<sal_uInt32>(nBytesToRead) > nRead )
- {
- // usually that means that the stream was read till the end
- // TODO/LATER: it is better to get rid of this optimization by avoiding using of multiple temporary files ( there should be only one temporary file? )
- mnCachedPos = mpStream->Tell();
- mbHasCachedPos = true;
-
- mpStream = nullptr;
- if ( mpTempFile )
- mpTempFile->CloseStream();
- }
-
return nRead;
}
sal_Int32 SAL_CALL OTempFileService::readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
@@ -233,17 +218,6 @@ void SAL_CALL OTempFileService::closeOutput( )
mbOutClosed = true;
- // TODO/LATER: it is better to get rid of this optimization by avoiding using of multiple temporary files ( there should be only one temporary file? )
- if ( mpStream )
- {
- mnCachedPos = mpStream->Tell();
- mbHasCachedPos = true;
-
- mpStream = nullptr;
- if ( mpTempFile )
- mpTempFile->CloseStream();
- }
-
if ( mbInClosed )
{
// stream will be deleted by TempFile implementation
@@ -260,23 +234,7 @@ void OTempFileService::checkError () const
void OTempFileService::checkConnected ()
{
if (!mpStream && mpTempFile)
- {
mpStream = mpTempFile->GetStream( StreamMode::STD_READWRITE );
- if ( mpStream && mbHasCachedPos )
- {
- mpStream->Seek( sal::static_int_cast<std::size_t>(mnCachedPos) );
- if ( mpStream->SvStream::GetError () == ERRCODE_NONE )
- {
- mbHasCachedPos = false;
- mnCachedPos = 0;
- }
- else
- {
- mpStream = nullptr;
- mpTempFile->CloseStream();
- }
- }
- }
if (!mpStream)
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );