summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-02-17 09:02:45 +0100
committerEike Rathke <erack@redhat.com>2022-02-17 15:06:12 +0100
commit41ca0b7262ca52646e935e41a187c5742c3993bb (patch)
tree814a85e3aa53f51071b840a2e4720dbba27e4905 /sc
parent2cbf83e20889351e2d2a6e29e5c7d9250af58647 (diff)
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 <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/docshell/impex.cxx37
1 files changed, 3 insertions, 34 deletions
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), "");
}
}