Actions
Feature #6173
closedre.cのrb_memsearch()におけるmemchr()の利用
Feature #6173:
re.cのrb_memsearch()におけるmemchr()の利用
Description
re.cのrb_memsearch()では、m == 1な場合にはfor文で各バイトと比較していますが、memchr()を用いると性能の改善がみられます。
次のようなベンチマークを実行したところ、以下のような結果となりました。
require 'benchmark'
str = "hoge" * 10000 + "\n"
Benchmark.bm do |x|
x.report do
str.index("\n")
end
end
trunk(r35083):
user system total real
0.000000 0.000000 0.000000 ( 0.000185)
proposal:
user system total real
0.000000 0.000000 0.000000 ( 0.000018)
patchを添付します。
Files
Actions