diff options
-rw-r--r-- | editeng/source/editeng/ContentNode.cxx | 5 | ||||
-rw-r--r-- | include/rtl/ustring.hxx | 14 | ||||
-rw-r--r-- | sal/osl/w32/file_url.cxx | 2 | ||||
-rw-r--r-- | stoc/source/security/permissions.cxx | 3 |
4 files changed, 14 insertions, 10 deletions
diff --git a/editeng/source/editeng/ContentNode.cxx b/editeng/source/editeng/ContentNode.cxx index de5e2150b151..b7e7f4b0e8ee 100644 --- a/editeng/source/editeng/ContentNode.cxx +++ b/editeng/source/editeng/ContentNode.cxx @@ -564,10 +564,7 @@ void ContentNode::SetChar(sal_Int32 nPos, sal_Unicode c) void ContentNode::Insert(const OUString& rStr, sal_Int32 nPos) { - if (nPos == 0 && maString.getLength() == 0) - maString = rStr; // avoid allocation - else - maString = maString.replaceAt(nPos, 0, rStr); + maString = maString.replaceAt(nPos, 0, rStr); } void ContentNode::Append(std::u16string_view rStr) diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index d4f54f76a1f6..3a6531b4f3a5 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -2631,8 +2631,6 @@ public: } #endif -// hide this from internal code to avoid ambiguous lookup error -#ifndef LIBO_INTERNAL_ONLY /** Returns a new string resulting from replacing n = count characters from position index in this string with newStr. @@ -2652,7 +2650,6 @@ public: rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData ); return OUString( pNew, SAL_NO_ACQUIRE ); } -#endif #ifdef LIBO_INTERNAL_ONLY SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const @@ -2661,6 +2658,17 @@ public: rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() ); return OUString( pNew, SAL_NO_ACQUIRE ); } + // Disambiguation + template <std::size_t N> + SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const sal_Unicode (&newStr)[N] ) const + { + return replaceAt(index, count, std::u16string_view(newStr, N - 1)); + } + template <class T, std::enable_if_t<std::is_convertible_v<T, std::u16string_view>, int> = 0> + SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const T& newStr ) const + { + return replaceAt(index, count, std::u16string_view(newStr)); + } #endif /** diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx index e074fbff54e6..82428a326621 100644 --- a/sal/osl/w32/file_url.cxx +++ b/sal/osl/w32/file_url.cxx @@ -424,7 +424,7 @@ DWORD IsValidFilePath(const OUString& path, DWORD dwFlags, OUString* corrected) // Correct path by merging consecutive slashes: if (o3tl::starts_with(*oComponent, u"\\") && corrected != nullptr) { sal_Int32 i = oComponent->data() - lastCorrected.getStr(); - *corrected = lastCorrected.replaceAt(i, 1, {}); + *corrected = lastCorrected.replaceAt(i, 1, std::u16string_view{}); //TODO: handle out-of-memory lastCorrected = *corrected; oComponent = lastCorrected.subView(i); diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx index 77da8459987b..b99aa9420a59 100644 --- a/stoc/source/security/permissions.cxx +++ b/stoc/source/security/permissions.cxx @@ -327,9 +327,8 @@ FilePermission::FilePermission( // correct win drive letters if (9 < m_url.getLength() && '|' == m_url[ 9 ]) // file:///X| { - constexpr OUStringLiteral s_colon = u":"; // common case in API is a ':' (sal), so convert '|' to ':' - m_url = m_url.replaceAt( 9, 1, s_colon ); + m_url = m_url.replaceAt(9, 1, u":"); } #endif } |