2015/07/31分のコミットです。
CHANGELOGへの追加はありませんでした。
Avoid calling to_s on nil in journey/formatter
actionpack/lib/action_dispatch/journey/formatter.rb
の修正です。
generate
メソッドで、defaultの値がnilの場合に、不要なStringへの変換を行わないよう修正しています。
以降、昨日同様性能改善のコミットが続きます。
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
固定で使用している文字列をfreeze
して、String objectを使いまわすよう修正しています。
Only allocate new string when needed
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
controllerの先頭からスラッシュを削除する処理で、最初に先頭がスラッシュかチェックし、スラッシュの場合のみ削除するよう修正しています。
Avoid hash duplication by skipping mutation
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
不要なHashのduplication処理を削除しています。
Decrease allocations in transliterate
activesupport/lib/active_support/inflector/transliterate.rb
の修正です。
固定で使用している文字列をfreeze
して、String objectを使いまわすよう修正しています。
activesupport/lib/active_support/core_ext/string/inflections.rb
、
activesupport/lib/active_support/multibyte/unicode.rb
の修正です。
固定で使用している文字列をfreeze
して、String objectを使いまわすよう修正しています。
Don't allocate array when not necessary
actionview/lib/action_view/helpers/tag_helper.rb
の修正です。
tag_options
メソッドで出力内容を構築するのに、Arrayにデータを追加していき、最後にArray#*
でStringを生成していたのですが、
最初からStringクラスで値を管理し、不要なArrayを生成しないよう修正しています。
actionview/lib/action_view/renderer/partial_renderer.rb
の修正です。
固定で使用している文字列をfreeze
して、String objectを使いまわすよう修正しています。
actionpack/lib/action_dispatch/journey/formatter.rb
の修正です。
generate
メソッドのmissing_keys
変数の初期値を空の配列からnil
に変更しています。
missing_keys
変数はエラーメッセージを生成する場合しか使わず、使用しない事が多いので、不要なArray objectの生成を避けるために修正したようです。
Remove (another) array allocation
actionpack/lib/action_dispatch/journey/formatter.rb
の修正です。
今度はmissing_keys
メソッドの中のmissing_keys
変数の初期値を空の配列からnil
に変更しています。 理由は先程のコミットと同様。
Use delete_if instead of each; delete(key)
actionpack/lib/action_dispatch/journey/formatter.rb
の修正です。
each
したブロックの中でdelete
処理を呼び出しいたのを、delete_if
を使用するよう修正してます。
- parameterized_parts.each do |bad_key, _| - next if keys_to_keep.include?(bad_key) - parameterized_parts.delete(bad_key) + parameterized_parts.delete_if do |bad_key, _| + !keys_to_keep.include?(bad_key)
delete_if
の方が少々早いとの事。性能測定結果は下記通り。
Calculating ------------------------------------- each; delete 35.166k i/100ms delete_if 36.416k i/100ms ------------------------------------------------- each; delete 478.026k (± 8.5%) i/s - 2.391M delete_if 485.123k (± 7.9%) i/s - 2.440M
Array#any? is slower and not the inverse of Array#empty?
actionpack/lib/action_dispatch/journey/formatter.rb
の修正です。
Arrayに値が設定されているかどうかの確認にArray#any?
を使用していたのを、Array#empty?
を使用するよう修正しています。
Array#empty?
の方が早い為との事。性能測定結果。
empty_array = [] small_array = [1] * 30 bigger_array = [1] * 300 Benchmark.ips do |x| x.report('empty !empty?') { !empty_array.empty? } x.report('small !empty?') { !small_array.empty? } x.report('bigger !empty?') { !bigger_array.empty? } x.report('empty any?') { empty_array.any? } x.report('small any?') { small_array.any? } x.report('bigger any?') { bigger_array.any? } end
Calculating ------------------------------------- empty !empty? 132.059k i/100ms small !empty? 133.974k i/100ms bigger !empty? 133.848k i/100ms empty any? 106.924k i/100ms small any? 85.525k i/100ms bigger any? 86.663k i/100ms ------------------------------------------------- empty !empty? 8.522M (± 7.9%) i/s - 42.391M small !empty? 8.501M (± 8.5%) i/s - 42.202M bigger !empty? 8.434M (± 8.6%) i/s - 41.894M empty any? 4.161M (± 8.3%) i/s - 20.743M small any? 2.654M (± 5.2%) i/s - 13.256M bigger any? 2.642M (± 6.4%) i/s - 13.173M
Merge pull request #20992 from JuanitoFatas/fix/bin-setup-script
railties/lib/rails/generators/rails/app/templates/bin/setup
の修正です。
以前、bin/setup
内のコマンドが失敗した場合、即時failするよう修正されたのですが、bundle check
については、即時failしないよう修正しています。
- system!('bundle check') or system!('bundle install') + system('bundle check') or system!('bundle install')
bundle check
に失敗した場合、次にbundle install
を実行する想定なので、failされるとまずい為、との事です。
Merge pull request #21063 from cmisenas/fix-guides-warning-env
guides/Rakefile
の修正です。
warning flagの指定方法が誤っていたのを修正しています。