2015/10/16分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Add an immutable string type to opt out of string duping
whereraises ArgumentError on unsupported types.
Expand support for ActiveSupport::TimeWithZone#utc?
activesupport/lib/active_support/time_with_zone.rbの修正です。
ActiveSupport::TimeWithZone#utc?メソッドのチェック処理を改善し、Etc/UTCやEtc/Universal`のような、utcのaliasについても、trueを返すよう修正しています。
def utc? - time_zone.name == 'UTC' + period.offset.abbreviation == :UTC || period.offset.abbreviation == :UCT
aliasになっているgmt?メソッドも同様の挙動になります。協定世界時を表すタイムゾーンって、割と多いんですねえ。参考: タイムゾーンの一覧
Add an immutable string type to opt out of string duping
Active Modelの修正です。immutable stringを扱う為の、ImmutableStringをtype moduleに追加しています。
実装的には、cast_valueした際にfreezeした値を返すようになっています。
All strings returned by ImmutableString should be frozen
activemodel/lib/active_model/type/immutable_string.rb、
activemodel/lib/active_model/type/string.rbの修正です。
ImmutableStringクラスが返す値は、全てfreezeするよう修正しています。
先のコミットでは、booleanを表す文字列(t、f)はfreezeしていなかったのですが、そちらの文字列についてもfreezeするよう修正しています。
make string allocation constant regardless of column count
activesupport/lib/active_support/core_ext/object/deep_dup.rbの修正です。
deep_dupメソッドで、keyがStringかつfreeze済みの場合、keyについては再度deep_dupを行わないよう修正しています。
カラム数が多くなってしまった場合に、Active Recordが生成するオブジェクトの数が大変多くなってしまう、という問題があり、その為の対応として行ったとの事です。
Update active_record_migrations.md
rails guideのActive Record Migrationsの修正です。
Resetting the Databaseの項、schema.rb 及び structure.rbのpathにdbを追加しています。
drop array allocations when iterating over the hash
activesupport/lib/active_support/core_ext/object/deep_dup.rbの修正です。
deep_dupメソッドで、繰り返し処理を行うのにeach_with_objectを使用していたのを、each_pairを使用するよう修正しています。
each_with_objectだと、key / valueペア毎にArrayのアロケート処理が発生してしまう為、アロケートを減らす為に、each_pairを使用するよう修正したとの事です。こちらも、先のコミット同様、Active Recordが生成するオブジェクトの数が多くなってしま問題のた為の対応として行ったとの事です。
[ci skip] readonly options has been removed
activerecord/lib/active_record/associations.rbのdocの修正です。
has_and_belongs_to_manyのdocに、使用出来ない:readonlyオプションについての説明があったので、削除しています。
where raises ArgumentError on unsupported types.
activerecord/lib/active_record/relation/query_methods.rbの修正です。
Active Recordのwhereメソッドに、使用できない型のオブジェクトが渡された場合に、ArgumentErrorをraiseするよう修正しています。
例。
User.where(1) # => ArgumentError: Unsupported argument type: 1 (Fixnum)