Opened 19 years ago

Last modified 18 years ago

#5422 closed

New functionality for wxString::Find()

Reported by: bobcavanaugh Owned by: vadz
Priority: low Milestone:
Component: Version:
Keywords: Cc: bobcavanaugh, vadz, mfielding
Blocked By: Blocking:
Patch: yes


The wxString Find() method does not allow for
searching for strings in a backwards direction or
in a case-insensitive manner. Also, the method
depends on a wxChar() method which appears to be
pretty inefficient. I have added an implementation
of the Boyer-Moore fast searching algorithm and
flags to allow selection of direction and case
sensitivity. I am currently using this new
method for Find and Replace in a dedicated text
editor in my application and the response times
are very satisfactory.

Attachments (1)

strings.patch download (10.3 KB) - added by bobcavanaugh 19 years ago.
Patch file containing new functionality for wxString::Find()

Download all attachments as: .zip

Change History (6)

Changed 19 years ago by bobcavanaugh

Patch file containing new functionality for wxString::Find()

comment:1 Changed 19 years ago by vadz

Having BM is nice but I'm not sure that Find() should be
using it -- it's a generic purpose function and it's very
often used for the short strings where it is not worth it.

The "wChar() method" is just your libc strchr() and
normally it is quite efficient (at least it is practically
always hand optimized), so I don't know what do you
mean by this?

Anyhow, I feel that this deserves [more] discussion on
the list first.


comment:2 Changed 19 years ago by mfielding

Could you change it to a FindEx a la windows api, or FindBM? Definitely in favour of keeping existing libc code version for general purpose.

comment:3 Changed 19 years ago by bobcavanaugh

I suggested this change to the wxString() class since it
seemed to be the most logical place to put it. The motivation
for this change was to provide an easy way to implement
direction selection and case sensitivity selection for the
wxFindReplaceDialog() class. By directly coding the Boyer-
Moore algorithm, I saw improvement over the methods
provided by wxChar(). Instead of incorporating this directly
into the wxString::Find() method, why not make the Find()
method a pointer where the wxString() constructor defaults to
the existing routines but can be re-directed as desired? The
BM structures and methods can then be implemented in a
separate class that can either be a friend or a predecessor to
wxString(). Alternatively it can be made part of a predecessor
to wxFindReplaceDialog(). Thoughts?

comment:4 Changed 19 years ago by mfielding

As Vadim suggested, the best place to dicuss this is on wxdev. Hunt for the mailing list info at (under Community). I suggest you summarise your (and our) positions and put your idea to the list.

What's wrong with FindEx? It seems a lot simpler to use and implement than your suggestion of function pointers, and would allow people to use the old (simple) Find syntax or your new one in the same program.

BTW, Find already appears to allow backward searches?

When is this BM algorithm useful? Large amounts of text, or any?

comment:5 Changed 18 years ago by vadz

As the plans to replace wxString with std::string become
more and more close to reality, it also becomes clear that this
patch is never going to be applied so I'm closing it.


Note: See TracTickets for help on using tickets.