Bug 132388 - BASIC: Replace is awfully slow
Summary: BASIC: Replace is awfully slow
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.1 all versions
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:7.0.0
Keywords: perf
Depends on:
Blocks:
 
Reported: 2020-04-24 21:48 UTC by Mike Kaganski
Modified: 2020-04-28 10:44 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2020-04-24 21:48:13 UTC
> Sub TestReplace
>   n=100000
>   s=Space(n) 
>   t=GetSystemTicks
>   s=Replace(s, " ", "*",1,-1,1) 
>   Msgbox "time=" & (GetSystemTicks-t)
> End Sub

This code runs about 7 s on my system, and time increases as O(n^2). It must run instantly.
Comment 1 Mike Kaganski 2020-04-24 21:53:59 UTC
https://gerrit.libreoffice.org/c/core/+/92884
Comment 2 Commit Notification 2020-04-25 06:01:32 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/dd06a8a2caf93707fbf29c7264cf41f8ec9d4c6d

tdf#132388: reimplement SbRtl_Replace

It will be available in 7.0.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.
Comment 3 Xisco Faulí 2020-04-28 10:32:09 UTC
time=26 in

Version: 7.0.0.0.alpha0+
Build ID: 4ba1909f12b49f020195b5e767045340717ce6df
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: x11; 
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded

@Mike Kaganski, thanks for fixing this issue!
Comment 4 Xisco Faulí 2020-04-28 10:44:45 UTC
time=86010 in

Version 4.1.0.0.alpha0+ (Build ID: efca6f15609322f62a35619619a6d5fe5c9bd5a)