Run Basic script: Sub TestSubstitute Dim s as String, i as Long, n as Long, t as Long, msg as String With ThisComponent.Sheets(0) n=20000 Do While n<=80000 .getCellByPosition(0,0).setFormula "=REPT("" *""; " & n & ")" t=GetSystemTicks() .getCellByPosition(0,1).setFormula "=SUBSTITUTE(A1;"" "";"" "")" Msgbox "n=" & n & " time=" & (GetSystemTicks()-t) n=n*2 Loop End With End Sub Result: n=20000 time=106 n=40000 time=507 n=80000 time=2230 The running time of the macro increases in proportion to the square of the length of the first argument SUBSTITUTE function. Should increase proportionally.
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/0b397d8ef0a2615e8e6202804ca2f6cb58436fa5 tdf#147109: Optimize ScInterpreter::ScSubstitute It will be available in 7.4.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Mike Kaganski committed a patch related to this issue. It has been pushed to "libreoffice-7-3": https://git.libreoffice.org/core/commit/7cddf9609df427c0a87d759cfeab2a6a34ef211b tdf#147109: Optimize ScInterpreter::ScSubstitute It will be available in 7.3.1. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Mike, thanks a lot!