From: Aristarkh A Zagorodnikov Date: 2001-08-31T16:23:36+09:00 Subject: [ruby-talk:20606] Re: String.subst[!] RCR > -----Original Message----- > From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org] > Sent: Friday, August 31, 2001 11:21 AM > To: ruby-talk ML > Subject: [ruby-talk:20605] Re: String.subst[!] RCR > > > Hi, > > In message "[ruby-talk:20604] String.subst[!] RCR" > on 01/08/31, "Aristarkh A Zagorodnikov" writes: > > | I have a proposal ;) Not sure eveyone will need it - maybe > everyone is > |satisfied with regexp matching performance, but sometimes I need a lot of > |string replacements which work fast, and do NOT need complex > regexp matching > |rules. I'm pretty sure that regexp matching isn't the fastest > operation out > |there (at least I believe it involves some kind of regexp > compilation). So, > |I'm proposing the following two methods (to be built in C). > > You mean you want "str.sub(pat, new)" without using regular > expression? > > Regular expression search is pretty fast for most of the cases > (especially for fixed patterns). It uses BM search inside. > As a result, str.sub(/foo/, 'bar') is often faster than your > str.subst('foo','bar'). I'm sure it _is_ faster ... but I believe that's it because of subst is written in ruby, while sub is in C. Aristarkh A Zagorodnikov, Lead Programmer, W3D Group http://www.w3d.ru /// xm@w3d.ru /// ICQ UIN 36987938