Issue #7368 has been updated by Glass_saga (Masaki Matsushita).

File patch2.diff added

?信???????????????????????????
??????????????????????????????????????????????????????

> ???????????????????????????EUC-JP???????????????好?????????????????????????????????????????????????????????????????????

rb_str_index()??????誤?????????対???????????????????????????誤????????????????????????????????????????????????????????????????????????
???????添????patch??修正????????????

> valid???invalid??????????????????????????????????????????????????????????

valid???invalid??????????????????被??索?????????invalid???????????????中??InvalidByteSequenceError???raise???????????????????????????????????????????????????
rb_memsearch()????中???正?????????????????????????????????????????????索???中??????????????????????????????????
??????被??索?????????invalid?????????????????????rb_enc_codepoint_len()????正?????????????????????????????????????索???????????????????????

誤?????????????????????修正??????patch???添????????????
----------------------------------------
Feature #7368: rb_str_each_line()???????????????????????????????
https://bugs.ruby-lang.org/issues/7368#change-33264

Author: Glass_saga (Masaki Matsushita)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 


rb_str_each_line()???memmem(3)???使??????[ruby-dev:45344] [Feature #6129]?????????????????????
string.c??????memmem(3)?????桦使????????索??rb_memsearch()??????????????
?索????????被?索????????両????valid???encoding???????????????????????????????????????????????????????????patch?????????????????
(???????????invalid??????????rb_enc_codepoint_len()?????????????????中??ArgumentError??????????????????????????????????????使?????????????????)

??????patch???以????????????????????

* string.c????memmem(3)??????????????????????????

* ???????????索?????????rb_default_rs???????????????rb_str_each_line()????memchr(3)??????????????????????????????????(trunk???string.c???6166?以??)??????
  rb_memsearch()???使??????索??????????????????????????????????????索??????????????????????????????????????????????

* ?索????????被?索?????????encoding???valid????????索?????????rb_default_rs????????????????????????????????????
  
* ??????????rb_str_each_line()???????宣??????????????????????????????????????????????????????????以??????????読?????????????

???????以????????????????????????????????????????

require 'benchmark'

str = "hogehifuga\n" * 100_0000

Benchmark.bm do |x|
  x.report("default rs") do
    10.times do
      str.each_line {}
    end
  end

  x.report("not default rs") do
    10.times do
      str.each_line("hi") {}
    end
  end
end

trunk(r37670):
       user     system      total        real
default rs  2.060000   0.000000   2.060000 (  2.055412)
not default rs  3.700000   0.000000   3.700000 (  3.698057)

proposed:
       user     system      total        real
default rs  2.100000   0.000000   2.100000 (  2.095167)
not default rs  2.150000   0.000000   2.150000 (  2.153824)

?索?????????rb_default_rs????????????????????????????????????????索?????????rb_default_rs?????????????????????????????????????????????確?????????????

??????????test-all????????????????????????????????????????????????????????設???????????????patch????????????????????????大???????????????
????????????????????????????


-- 
http://bugs.ruby-lang.org/