• KOBAYASHI Shuji's avatar
    Optimize `str_subseq` with `MRB_UTF8_STRING` to ASCII only string · 06bd4ffd
    KOBAYASHI Shuji authored
    ### Benchmark (with `MRB_UTF8_STRING`)
    
      ```ruby
      # benchmark.rb
      COUNT = 300000
      SIZE = 10000
      s = "a" * SIZE
      s.size  # set `MRB_STR_ASCII` flag
      i = 0
      while i < COUNT
        s[-1]
        i += 1
      end
      ```
    
    #### Before this patch:
    
      ```
      $ time mruby benchmark.rb
              2.06 real         2.05 user         0.00 sys
      ```
    
    #### After this patch:
    
      ```
      $ time mruby benchmark.rb
              0.05 real         0.04 user         0.00 sys
      ```
    06bd4ffd
string.c 79.7 KB