From: Tom Sawyer Date: 2002-07-11T02:07:51+09:00 Subject: Re: String#split converts string args to regexes -- ? ummm..the thread is called String#split converts... but i am suprised with my #index results: it is about 4x as fast with a regexp versus a string. how is this possible? split is around 4x times faster with a string, but index is 4x as slow? even if regexp is highly optimized, it must still entail some overhead that a pure string can do without, but perhaps the difference it's quite small. yet, the split example makes me wonder. what's going on here? ~transami On Wed, 2002-07-10 at 10:46, ts wrote: > >>>>> "T" == Tom Sawyer writes: > > T> s = "xyz" * 1000000 > T> a1 = s.split('y') > > It don't use String#index in this case > > T> On Wed, 2002-07-10 at 09:24, Yukihiro Matsumoto wrote: > >> Hi, > >> > >> In message "Re: String#split converts string args to regexes -- ?" > >> on 02/07/10, Tom Sawyer writes: > >> > >> |and, if implemented without regexps, could easily boost performance, > >> |which IMHO is an important bonus considering speed is probably the > >> |primary site against ruby in comparison to perl and python. > >> > >> regex is highly optimized for searching. search using regex > >> (e.g. str.index(/pat/)) is almost always faster than search using > >> strings (e.g. str.index("pat")). > ^^^^^^^^^^^^^^^^^^^^^ > > > > Guy Decoux > -- ~transami "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin