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

File patch3.diff added

????????????????????????????????????????????????????????String????正?????????????????????????????正????????????????????????????????????????????????????????好???????????????????????????
???????????????????default_rs??????????????memchr??????????????????正????????????????????????????????????????????????????????
?正??????????????????????????????????????中?????????????????????????????default_rs以????????????????????????????????????

????????????????????????????????????????????????????????????????正???????????????????????????????????????????統???????????????????????????????????????????????????????????????????

添?????patch????????????????????????rb_memsearch()???使?????????????????????????????????????????
rb_memsearch()????????memchar???memmem(3)???使?????????????正?????????????????????????????????????
???????????????????????default_rs????????????????????統??????????????????

以?????[ruby-dev:46523]?????????????????????????????????

trunk(r41584):
       user     system      total        real
default rs  2.060000   0.000000   2.060000 (  2.068874)
not default rs  3.660000   0.110000   3.770000 (  3.780576)

proposal
       user     system      total        real
default rs  2.160000   0.010000   2.170000 (  2.185718)
not default rs  2.350000   0.000000   2.350000 (  2.374584)
----------------------------------------
Feature #7368: rb_str_each_line()???????????????????????????????
https://bugs.ruby-lang.org/issues/7368#change-40188

Author: Glass_saga (Masaki Matsushita)
Status: Assigned
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: core
Target version: next minor


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/