From: Eric Wong Date: 2014-10-10T00:55:56+00:00 Subject: [ruby-core:65575] Re: [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string Current patch (named "opt_str_lit" insn): http://80x24.org/spew/m/opt-str-lit-v1%40m.txt One VM instruction now optimizes away object allocation for string literals in the following cases: * "lit" % obj * str << "lit" * "lit" + str * str + "lit" * "lit" * num * "lit" === obj * obj === "lit" * "lit" == str * str == "lit" * "lit" != str * str != "lit" * hash["lit"] * hash["lit"] = obj It is also in the "opt_str_lit" branch of git://bogomips.org/ruby.git We may rework the current BOP_ redefinition checks via generated code to make it easier to extend to args of common operations: * String#{gsub,tr,delete,squeeze,split,unpack}) * Hash#{include?,#key?} ... * Array#{pack,include?,join} ... Basically any common operation which takes a string literals.