[wx-dev] [ wxwindows-Patches-1946506 ] wxString::Replace() very slow

SourceForge.net noreply at sourceforge.net
Sat May 3 19:20:41 PDT 2008


Patches item #1946506, was opened at 2008-04-19 03:35
Message generated for change (Comment added) made by sf-robot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=309863&aid=1946506&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: Johannes Kulick (hildensia)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxString::Replace() very slow

Initial Comment:
When you do a global replace on very large Strings with a lot of replacements (>10000 and so on) wxString::Replace() gets really slow. (> 20 s)

The problem is, that the string is copied every time a replacement is done, because of the use of wxStringImpl::replace().

I've rewritten wxString::Replace() to copy the string only once. It results in a ca. five times faster Replace().

----------------------------------------------------------------------

>Comment By: SourceForge Robot (sf-robot)
Date: 2008-05-03 19:20

Message:
Logged In: YES 
user_id=1312539
Originator: NO

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

----------------------------------------------------------------------

Comment By: Vaclav Slavik (vaclavslavik)
Date: 2008-04-19 04:18

Message:
Logged In: YES 
user_id=80834
Originator: NO

Couple of comments:

* Your patch doesn't apply on latest SVN sources (and it obviously isn't
for 2.8 branch). Also, please follow wx coding guidelines -- in particular,
don't use TABs.

* I think it's more likely the problem is caused by bad Replace()
implementation in UTF-8 build. I fixed that, if the problem persists
(because you don't use UTF-8 build), please update the patch to work with
latest SVN trunk (it would help to attach then benchmark you use, too).

* The patch's replacing loop unnecessarily calls operator+= for every
character in unmodified part, when it could simply do on append() to copy
the unmodified block.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=309863&aid=1946506&group_id=9863


More information about the wx-dev mailing list