diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-07-03 12:21:25 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-07-03 22:11:53 +0200 |
commit | afa5ade8b51d609ece8408506a14e3f169774960 (patch) | |
tree | e22df141cdfc1d2a2531d64980905743c6acb6cd /shell | |
parent | 71b7313aa2324b8f7da2026e7b7c2d1c942b497c (diff) |
Optimize a bit
Change-Id: Icccf4a93054780c7a111f664117b25821c47f700
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169906
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/win32/SysShExec.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx index d67e9b8f3c84..3d8d7b994474 100644 --- a/shell/source/win32/SysShExec.cxx +++ b/shell/source/win32/SysShExec.cxx @@ -308,15 +308,15 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa {}, 0); } } - pathname = o3tl::toU(path); + std::u16string_view resulting_path(o3tl::toU(path)); // ShellExecuteExW appears to ignore trailing dots, so remove them: - while (pathname.endsWith(".", &pathname)) {} - auto const n = pathname.lastIndexOf('.'); - if (n > pathname.lastIndexOf('\\')) { - auto const ext = pathname.copy(n + 1); - if (!ext.isEmpty()) { + while (o3tl::ends_with(resulting_path, u".", &resulting_path)) {} + auto const n = resulting_path.find_last_of('.'); + if (n != std::u16string_view::npos && n > resulting_path.find_last_of('\\')) { + auto const ext = resulting_path.substr(n + 1); + if (!ext.empty()) { OUString env; - if (osl_getEnvironment(OUString("PATHEXT").pData, &env.pData) + if (osl_getEnvironment(u"PATHEXT"_ustr.pData, &env.pData) != osl_Process_E_None) { SAL_INFO("shell", "osl_getEnvironment(PATHEXT) failed"); |