diff options
author | Noel Grandin <noelgrandin@collabora.co.uk> | 2022-10-24 09:06:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-10-24 10:10:54 +0200 |
commit | 1ea0ea19f1dc13c4191ab9d4222adfd2579b802c (patch) | |
tree | cb9db1f92030907dc31d86e8a308a45d7208eed1 /unotools | |
parent | 83334df9cfc34a2f740fe30db0f3359105cede83 (diff) |
tdf#133768 speed up temp file creation
Use DELETE_ON_CLOSE attribute, so we can avoid calling osl_removeFile.
Shaves 5% off the export time.
Change-Id: I4fef8f181ef7a92c4805cc5996c3a17800a22602
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141718
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/ucbhelper/tempfile.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index 61ef2d247c01..efeb872b5d6d 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -409,7 +409,11 @@ SvStream* TempFileFast::GetStream( StreamMode eMode ) if (!mxStream) { OUString aName = CreateTempNameFast(); +#ifdef _WIN32 + mxStream.reset(new SvFileStream(aName, eMode | StreamMode::TEMPORARY | StreamMode::DELETE_ON_CLOSE)); +#else mxStream.reset(new SvFileStream(aName, eMode | StreamMode::TEMPORARY)); +#endif } return mxStream.get(); } @@ -420,8 +424,13 @@ void TempFileFast::CloseStream() { OUString aName = mxStream->GetFileName(); mxStream.reset(); +#ifdef _WIN32 + // On Windows, the file is opened with FILE_FLAG_DELETE_ON_CLOSE, so it will delete as soon as the handle closes. + // On other platforms, we need to explicitly delete it. +#else if (!aName.isEmpty() && (osl::FileBase::getFileURLFromSystemPath(aName, aName) == osl::FileBase::E_None)) File::remove(aName); +#endif } } |