From: "charliesome (Charlie Somerville)" Date: 2013-08-31T22:27:52+09:00 Subject: [ruby-core:56939] [ruby-trunk - Bug #8847] opt_regexpmatch2 does not use method caching Issue #8847 has been updated by charliesome (Charlie Somerville). nagachika: There's no incorrect behaviour that r42742 fixes - it is merely a performance improvement. You can use the following benchmark script as a test: require "benchmark" puts Benchmark.measure { 1_000_000.times do 1 =~ // 1 =~ // 1 =~ // 1 =~ // 1 =~ // 1 =~ // 1 =~ // 1 =~ // end } Before my commit, I get this result: 0.330000 0.000000 0.330000 ( 0.332941) After my commit, I get: 0.240000 0.000000 0.240000 ( 0.241248) You can probably do something similar to verify your backport is correct. ---------------------------------------- Bug #8847: opt_regexpmatch2 does not use method caching https://bugs.ruby-lang.org/issues/8847#change-41497 Author: charliesome (Charlie Somerville) Status: Closed Priority: Normal Assignee: charliesome (Charlie Somerville) Category: Target version: ruby -v: ruby 2.1.0dev (2013-08-31 trunk 42741) [x86_64-darwin12.4.0] Backport: 1.9.3: UNKNOWN, 2.0.0: REQUIRED The opt_regexpmatch2 instruction does not use method caching, instead it uses rb_funcall internally. opt_regexpmatch2 is emitted by the compiler when a literal regexp is on the right hand side of the =~ operator. This means a full method lookup must be performed every time the receiver of the =~ method call is not a String. -- http://bugs.ruby-lang.org/