[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Regexps Profiling

Igor Maximchuk

11/6/2003 9:32:00 PM

Hello,

I was recently using module 'profile' to profile code, that used Regexps. It
was discovered, that Regexp or String class methods usage (Regexp#match,
String:#=~) is being profiled only when there exists explicit call like
r.match(s)
or s =~ r, while s =~ /foo/ is not considered as a method call.
And some testing shows, that s =~ /foo/ is a little faster than r.match(s)

Questions:
Are Regexp#match, String#scan, etc actually wrappings for something
"internal" (=~)?
How is this related to object-oriented regular expressions paradigm?

example code:

require 'profile'

s = "abc"
r = /(.)/
s =~ /(.)/
#r.match(s) #uncomment to see the difference
#s =~ r #uncomment to see the difference