From: Eric Hodel Date: 2006-07-30T08:04:24+09:00 Subject: Re: Slow regular expressions On Jul 29, 2006, at 7:52 AM, Caleb Clausen wrote: > On 7/29/06, Jeremy Henty wrote: >> Yow! Calling String#match is 2-3 times as slow! Why is that? The >> overhead of calling the method? > > I was curious about this too. > It looks like it's the effort of computing a MatchData that takes all > the extra time. This snippet is just as slow as using #match: > > bm.report '=~ literal + $~' do > N.times do string =~ /a (.) c\s. e/ ; $~ end > end Yes, it is the work of constructing the MatchData object. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com