なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2014/11/19)

2014/11/19分のコミットです。

CHANGELOGへの追加はありませんでした。


Ruby on Rails 3.0 Release Notes: fix broken link

rails guideのRuby on Rails 3.0 Release Notesの修正です。

[Revamped Routes in Rails 3](https://medium.com/fusion-of-thoughts/revamped-routes-in-rails-3-b6d00654e5b0)のリンクが変わっていたのを修正しています。 3.0のRelease Notes、まだ見てる人いるんですねえ。


Remove call to key? in LazyAttributeHash#[]

activerecord/lib/active_record/attribute_set/builder.rbの修正です。

LazyAttributeHash#[]メソッドkey?メソッドの呼び出しを削除しています。

-      if delegate_hash.key?(key)
-        delegate_hash[key]
-      else
-        assign_default_value(key)
-      end
+      delegate_hash[key] || assign_default_value(key)

性能改善対応。


LazyAttributeHash is private

activerecord/lib/active_record/attribute_set/builder.rbの修正です。

LazyAttributeHashクラスに:nodoc:を指定しています。


Remove needless call to key? when building attributes

activerecord/lib/active_record/attribute_set/builder.rbの修正です。

LazyAttributeHash#assign_default_valueメソッドkey?メソッドの呼び出しを削除しています。

+      value_present = true
+      value = values.fetch(name) { value_present = false }

-      if values.key?(name)
-        delegate_hash[name] = Attribute.from_database(name, values[name], type)
+      if value_present
+        delegate_hash[name] = Attribute.from_database(name, value, typ

key?でチェックするのではなく、fetchメソッドで値の取得をしてるんですねえ。これも性能改善の為との事。


Make sure assert_select can assert body tag

Parse HTML as document fragmentの対応をrevertしています。

rails-dom-testingの方の変更に伴い、対応したようです。


Speed up integer casting from DB

activerecord/lib/active_record/type/integer.rbの修正です。

Integer#type_cast_from_databaseメソッドを追加しています。

元々cast_valueメソッドではrangeのチェック等を行っていたのですが、rangeチェック等は行わず、単純にto_iでIntegerへの変換処理のみ行っています。こちらも性能改善の為との事。


pull the preloader allocation in to a factory method

activerecord/lib/active_record/relation.rbの修正です。

preloaderの生成処理をメソッドに切り出していいます。


Improve the performance of reading attributes

ActiveRecordの修正です。

AttributeMethods::Read#_read_attributeメソッドを追加しています。基本的にはread_attributesメソッドと同じなのですが、こちらはprimary keyのチェックを行っておらず、その分高速なので、primary keyのチェックが不要な箇所ではこちらのメソッドを使用するよう修正しています。


Duplicated Hash key :prompt

actionview/test/template/date_helper_test.rbの修正です。

test_select_time_with_custom_promptselect_timeメソッドの引数に同じパラメータを2回設定してしまっていたので、片方削除しています。


Support symbol foreign key to delete

activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rbの修正です。

remove_foreign_keyメソッドのcolumnオプションにSymbolを指定した場合に、keyが削除されないバグがあったのを修正しています。columnオプションのStringへの変換処理が足りてなかったんですねえ。