From 181fc61c4cce5192e57657c313ee7fa4f640fb69 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 15 Feb 2021 12:49:30 +0100 Subject: Reuse known length of the temp dir path And make this code a bit more C++-ish. Change-Id: I59d4f46698ad4606f09e6ffcae8f205798b427ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110912 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sal/osl/w32/tempfile.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'sal/osl/w32') diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx index 5424bfbde077..a4c272e57768 100644 --- a/sal/osl/w32/tempfile.cxx +++ b/sal/osl/w32/tempfile.cxx @@ -21,6 +21,7 @@ #include #include +#include #include "file-impl.hxx" #include "file_error.hxx" @@ -227,16 +228,12 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) } else if ( nLength ) { - rtl_uString *ustrTempPath = nullptr; - if ( '\\' == lpBuffer[nLength-1] ) - lpBuffer[nLength-1] = 0; - - rtl_uString_newFromStr( &ustrTempPath, o3tl::toU(lpBuffer) ); + --nLength; - error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); + const OUString ustrTempPath(o3tl::toU(lpBuffer), static_cast(nLength)); - rtl_uString_release( ustrTempPath ); + error = osl_getFileURLFromSystemPath(ustrTempPath.pData, pustrTempDir); } else error = oslTranslateFileError( GetLastError() ); -- cgit