comphelper/source/eventattachermgr/eventattachermgr.cxx | 8 +++---- comphelper/source/misc/DirectoryHelper.cxx | 18 ++++++++-------- include/comphelper/DirectoryHelper.hxx | 3 +- 3 files changed, 15 insertions(+), 14 deletions(-)
New commits: commit 08a72cbb06776e83475e70e0ee5d6c0ca572944e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Apr 21 15:39:10 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Apr 22 13:29:24 2022 +0200 use more string_view in comphelper Change-Id: Ib186d2c9aa8458ddbdd14dd44e2d3938f0f26ad2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133269 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx index 4c7be22c2bb1..a08c6cf4777a 100644 --- a/comphelper/source/eventattachermgr/eventattachermgr.cxx +++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx @@ -456,10 +456,10 @@ void SAL_CALL ImplEventAttacherManager::revokeScriptEvent for( const auto& rObj : aList ) detach( nIndex, rObj.xTarget ); - OUString aLstType = ListenerType; - sal_Int32 nLastDot = aLstType.lastIndexOf('.'); - if (nLastDot != -1) - aLstType = aLstType.copy(nLastDot+1); + std::u16string_view aLstType = ListenerType; + size_t nLastDot = aLstType.rfind('.'); + if (nLastDot != std::u16string_view::npos) + aLstType = aLstType.substr(nLastDot+1); auto aEvtIt = std::find_if(aIt->aEventList.begin(), aIt->aEventList.end(), [&aLstType, &EventMethod, &ToRemoveListenerParam](const ScriptEventDescriptor& rEvent) { diff --git a/comphelper/source/misc/DirectoryHelper.cxx b/comphelper/source/misc/DirectoryHelper.cxx index 248e7af185b7..badfe9b62d80 100644 --- a/comphelper/source/misc/DirectoryHelper.cxx +++ b/comphelper/source/misc/DirectoryHelper.cxx @@ -19,24 +19,24 @@ namespace comphelper { typedef std::shared_ptr<osl::File> FileSharedPtr; -OUString DirectoryHelper::splitAtLastToken(const OUString& rSrc, sal_Unicode aToken, - OUString& rRight) +std::u16string_view DirectoryHelper::splitAtLastToken(std::u16string_view rSrc, sal_Unicode aToken, + OUString& rRight) { - const sal_Int32 nIndex(rSrc.lastIndexOf(aToken)); - OUString aRetval; + const size_t nIndex(rSrc.rfind(aToken)); + std::u16string_view aRetval; - if (-1 == nIndex) + if (std::u16string_view::npos == nIndex) { aRetval = rSrc; rRight.clear(); } else if (nIndex > 0) { - aRetval = rSrc.copy(0, nIndex); + aRetval = rSrc.substr(0, nIndex); - if (rSrc.getLength() > nIndex + 1) + if (rSrc.size() > nIndex + 1) { - rRight = rSrc.copy(nIndex + 1); + rRight = rSrc.substr(nIndex + 1); } } @@ -210,4 +210,4 @@ bool DirectoryHelper::moveDirContent(const OUString& rSourceDirURL, return bError; } -} \ No newline at end of file +} diff --git a/include/comphelper/DirectoryHelper.hxx b/include/comphelper/DirectoryHelper.hxx index 56c017da476d..321e9f960e4a 100644 --- a/include/comphelper/DirectoryHelper.hxx +++ b/include/comphelper/DirectoryHelper.hxx @@ -21,7 +21,8 @@ namespace comphelper class COMPHELPER_DLLPUBLIC DirectoryHelper { public: - static OUString splitAtLastToken(const OUString& rSrc, sal_Unicode aToken, OUString& rRight); + static std::u16string_view splitAtLastToken(std::u16string_view rSrc, sal_Unicode aToken, + OUString& rRight); static bool fileExists(const OUString& rBaseURL); static bool dirExists(const OUString& rDirURL);