sc/source/ui/docshell/impex.cxx | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-)
New commits: commit 41ca0b7262ca52646e935e41a187c5742c3993bb Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Feb 17 09:02:45 2022 +0100 Commit: Eike Rathke <er...@redhat.com> CommitDate: Thu Feb 17 15:06:12 2022 +0100 Revert "Resolves: tdf#147421 Do not use OUString::replaceAll() to strip null-bytes" This reverts commit 4b0c17609c2cca326bbcc9e8488a327a4a9ea952. Reason for revert: it's possible now to revert to previous simpler code after commit 4e4a01302a140d75a49055821b3197a2eda81db5 Related: tdf#147421: optimize O(U)String's replaceAll* Change-Id: Iaefac917afbc9c587e75c38457dd9ea87e4f5861 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130017 Tested-by: Jenkins Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index a2b0463f439d..953aa0eb8167 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1767,41 +1767,10 @@ void ScImportExport::EmbeddedNullTreatment( OUString & rStr ) // The normal case is no embedded NULL, check first before de-/allocating // ustring stuff. - const sal_Unicode cNull = 0; - sal_Int32 i; - if ((i = rStr.indexOf( cNull)) >= 0) + sal_Unicode cNull = 0; + if (rStr.indexOf( cNull) >= 0) { - // Do not use OUString::replaceAll(...,""), in case of repeated null - // bytes that reallocates for each and for massive amounts takes - // ~endless. See tdf#147421 with 3577016 trailing null-bytes. - const sal_Int32 nLen = rStr.getLength(); - OUStringBuffer aBuf( nLen); - sal_Int32 s = 0; - sal_Unicode const * const p = rStr.getStr(); - do - { - // Append good substring. - aBuf.append( p + s, i - s); - // Skip all cNull. - while (++i < nLen && *(p+i) == cNull) - ; - // Find next cNull after good if characters left, else end. - if (i < nLen) - { - s = i; - i = rStr.indexOf( cNull, i); - } - else - { - s = nLen; - } - } - while (0 <= i && i < nLen); - // Append good trailing substring, if any. - if (s < nLen) - aBuf.append( p + s, nLen - s); - - rStr = aBuf.makeStringAndClear(); + rStr = rStr.replaceAll( std::u16string_view( &cNull, 1), ""); } }