[ruby-cvs:65404] normal:r58233 (trunk): compile.c: optimize literal String range in case/when dispatch

normal at ruby-lang.org normal at ruby-lang.org
Sun Apr 2 06:38:25 JST 2017


normal	2017-04-02 06:38:25 +0900 (Sun, 02 Apr 2017)

  New Revision: 58233

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58233

  Log:
    compile.c: optimize literal String range in case/when dispatch
    
    This is similar in spirit to opt_case_dispatch as the literal
    Range here is guaranteed to be immutable when used for
    checkmatch.
    
    Normal range literals with non-frozen strings are actually
    mutable, as Range#begin and Range#end exposes the strings to
    modification.  So those Range objects cannot be frozen without
    breaking compatibility, but Ranges in case/when dispatch can be
    frozen at compile time.
    
    * compile.c (iseq_peephole_optimize): persistent Range creation
      when String literals are used as beginning and end of range
      when used for case/when dispatch.
      [ruby-core:80290] [Feature #13355]

  Modified files:
    trunk/compile.c
    trunk/test/ruby/test_optimization.rb


More information about the ruby-cvs mailing list