Speed up searching for text references a bit
Merge request reports
Activity
Filter activity
@yorickpeterse Looks good! For my own curiosity, could you explain why this is faster?
Edit: Derp, it makes sense to check the ancestry before doing the more expensive match. The
match
to=~
change is just stylistic, right?Edited by Robert Speicher@rspeicher No,
String#match
allocates and returns a MatchData object whileString#=~
returns a Fixnum (= number of matches) or nil. MRI also has some extra optimizations forString#=~
making it faster thanString#match
(though on Rubinius both perform more or less the same, unsure about JRuby).Edited by yorickpeterse-staging@yorickpeterse Good to know, thanks.
mentioned in commit 249a9476
Please register or sign in to reply