Issue #6129 has been updated by Glass_saga.

File patch2.diff added

Nobuyoshi Nakada wrote:
>* ??????違?????≪?若????с????号??????????????
>* ????????????ゃ?????絖?????筝?????????????????翫??????????????
>??障?????菴遵?????????????潟?若???????√?????潟?若?????????????茲??????????????????????????障????? ???茲????羝???????????c???????с??????????????

??????違?????≪?若????с????号????????????????????????ゃ?????с????????罨<????????????潟???????若???絎?茵???????帥?障????????

require 'benchmark'

rs = "\n" * ARGV.first.to_i
str = "hoge#{rs}fuga" * 10_0000

Benchmark.bm do |x|
  x.report do
    str.each_line("") {|s| s }
  end
end

"\n" * 2 ???翫??

proposal:
       user     system      total        real
   0.070000   0.000000   0.070000 (  0.070409)

trunk:
       user     system      total        real 
   0.090000   0.000000   0.090000 (  0.094886)

"\n" * 100 ???翫??

proposal:
       user     system      total        real
   0.310000   0.000000   0.310000 (  0.307020)

trunk:
       user     system      total        real
   0.320000   0.000000   0.320000 (  0.320367)

篁ヤ???????????????g??????????壕?????絖???????違??絨???????翫?????????違?????≪?若????с????号?????????????障?????
?????違??紊??????????ゃ?????trunk????腮?綺?????????????障???????????荵≪?????篋??????????障???????с????????

>* ????????????ゃ?????絖?????筝?????????????????翫??????????????

???絲???????????罩c????????????障???????с????????

"陦ィ遉コ".encode("SJIS").each_line("\\").to_a.map{|s| s.encode("UTF-8") } #=> ["陦?", "遉?"]
(UTF-8??医????с??)

>??障?????菴遵?????????????潟?若???????√?????潟?若?????????????茲??????????????????????????障????? ???茲????羝???????????c???????с??????????????

line = rb_str_new5(str, s, sublen)?????????4茵????ゃ??????∽?違????????冴??篋??????с????障????????
??????篁ュ??????????ゃ???????茲????羝???????????c??????????????障?????

篁ヤ?????2??鴻????劫??????????違?????patch???羞私???????障?????

* rb_enc_left_char_head()???????????絖?紜????????????с??????????????????????
* configure???memmem()??膃3綣????needle???腥冴??翫?????榊?????????????違???????с?????с????????????c?????т信罩?
* line_yield()?????????∽?違??篏??????潟?若??????茲???????羝?
----------------------------------------
Feature #6129: String#each_line??????????memmem()?????
https://bugs.ruby-lang.org/issues/6129#change-24727

Author: Glass_saga
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 2.0.0


memmem()???????GNU??≦宍????ゃ??????∽?違??????????障????????string.c???rb_str_each_line()??у?純?с???????違?????memmem()???????????篋???????罅??????障?????

罨<?????潟???????若???絎?茵??????障????????

require 'benchmark'

str = "hogehifuga" * 100_0000

Benchmark.bm do |x|
  x.report do
    str.each_line("hi") {}
  end
end

腟????:

trunk(r34969):

       user     system      total        real  
   0.790000   0.000000   0.790000 (  0.795141) 

       user     system      total        real  
   0.790000   0.000000   0.790000 (  0.795141) 

       user     system      total        real  
   0.790000   0.000000   0.790000 (  0.795141) 

proposal:

       user     system      total        real   
   0.510000   0.000000   0.510000 (  0.507389)  

       user     system      total        real  
   0.530000   0.000000   0.530000 (  0.541944) 

       user     system      total        real   
   0.520000   0.000000   0.520000 (  0.522825)  

篁ヤ?????????????memmem()???????????篋???с????????若????潟?鴻??劫?????荀?????????障?????
篏?????????壕?????絖????rb_default_rs????筝???с???????翫??????≪??memchr()??????????蕭????????膣≪??茵???????????????????c????????冴??
?????????若????潟?鴻????劫???????????????rb_default_rs篁ュ?????壕?????絖???????絎?????????翫?????帥?с?????

patch???羞私???????障?????


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