From: zn@... Date: 2017-09-28T14:19:21+00:00 Subject: [ruby-core:83047] [Ruby trunk Feature#13943] Use unpack1 instead of unpack(template)[0] in erb.rb Issue #13943 has been updated by znz (Kazuhiro NISHIYAMA). Using benchmark_driver gem, `unpack1(template)` is about 1.07x faster than `unpack(template)[0]`. ``` % cat url_encode.yml prelude: | require 'erb' str = "Programming Ruby: The Pragmatic Programmer's Guide" benchmark: ERB::Util.url_encode(str) % benchmark_driver url_encode.yml -e ruby-base::$(rbenv root)/versions/git/bin/ruby -e ruby-unpack1::$(rbenv root)/versions/git2/bin/ruby benchmark results: Execution time (sec) name ruby-base ruby-unpack1 url_encode 1.793 1.665 Speedup ratio: compare with the result of `ruby-base' (greater is better) name ruby-unpack1 url_encode 1.077 ``` ---------------------------------------- Feature #13943: Use unpack1 instead of unpack(template)[0] in erb.rb https://bugs.ruby-lang.org/issues/13943#change-66970 * Author: znz (Kazuhiro NISHIYAMA) * Status: Assigned * Priority: Normal * Assignee: k0kubun (Takashi Kokubun) * Target version: ---------------------------------------- I think `unpack1(template)` is faster than `unpack(template)[0]`. Attached patch for `lib/erb.rb`. ---Files-------------------------------- erb-unpack1.diff (355 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: