[Patch] Use std::search in string::find

Dhruv Matani dhruvbird@gmx.net
Sun Jun 13 11:18:00 GMT 2004


On Sun, 2004-06-13 at 14:00, Paolo Carlini wrote:
> Dhruv Matani wrote:
> 
> >Here is a version that takes a const char*, size_type, and size_type, it
> >can be adopted easily if you feel it's fine.
> >  
> >
> Don't we agree with Matt that the first step is definitely make use of 
> algorithms
> in string? Afterwards, in case, we can conceive improving -slowly- the 
> former...

Ok, I have some numbers for the algorithms:

1. Re-implemented rr_find().
2. string::rfind.
3. Implemented using std::find_end().


>From the numbers on my system, it seems that find_end() could be
improved.

Do the numbers on your system agree?

-- 
        -Dhruv Matani.
http://www.geocities.com/dhruvbird/

Proud to be a Vegetarian.
http://www.vegetarianstarterkit.com/
http://www.vegkids.com/vegkids/index.html

-------------- next part --------------
[dhruv@localhost test]$ ./str_rfind 
Searching for: aabbaabbc*** in: aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy
Time taken: 0.1 seconds.
42
Time taken: 0.15 seconds.
42
Time taken: 0.24 seconds.
42
Searching for: aabbb*** in: aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy
Time taken: 0.21 seconds.
37
Time taken: 0.44 seconds.
37
Time taken: 0.47 seconds.
37
Searching for: xd*** in: aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy
Time taken: 0.29 seconds.
10
Time taken: 1.32 seconds.
10
Time taken: 0.56 seconds.
10
Searching for: very*** in: dhruv is a very very good boy ;-)
Time taken: 0.11 seconds.
16
Time taken: 0.48 seconds.
16
Time taken: 0.26 seconds.
16
Searching for: bad*** in: dhruv is a very very good boy ;-)
Time taken: 0.19 seconds.
4294967295
Time taken: 1 seconds.
4294967295
Time taken: 0.3 seconds.
4294967295
Searching for: extra irritating*** in: dhruv is a very very good boy ;-)
Time taken: 0.14 seconds.
4294967295
Time taken: 0.6 seconds.
4294967295
Time taken: 0.29 seconds.
4294967295
Searching for: this is a very long sentence*** in: this is a very long sentence this is a very this is a verty this is a very this is a very long sentenc
Time taken: 0.92 seconds.
0
Time taken: 2.5 seconds.
0
Time taken: 1.14 seconds.
0


More information about the Libstdc++ mailing list