なるようになるブログ

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

rails commit log流し読み(2018/04/27)

2018/04/27分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md


Reduce extra object creations in TaggedLogging

activesupport/lib/active_support/tagged_logging.rbの修正です。

TaggedLoggingでtagからStringを生成する際に、tagが一つしか無い場合は不要なオブジェクトを生成しないよう修正しています。


Reduce String allocations when building Action View tags

actionview/lib/action_view/helpers/tag_helper.rbの修正です。

TagBuilder#tag_optionメソッドでString#grubを使っていたのをString#grub!を使うようにして、不要なオブジェクトが生成されないよう修正しています。


Don't try to destoy the given string via method argument

actionview/lib/action_view/helpers/tag_helper.rbの修正です。

先のString#gsub!を使用するにした対応の影響で、tagをescapeしない際にFrozenErrorが発生してしまうようになっていたので、valuedupするようにして対応しています。


Don't dup Strings when jsonifying

activesupport/lib/active_support/json/encoding.rbの修正です。

EscapedString#to_jsonメソッドで、String#grubを使っていたのをString#grub!を使うようにして、不要なオブジェクトが生成されないよう修正しています。


Address Style/StringLiterals offence

actionview/lib/action_view/helpers/tag_helper.rbの修正です。

Stringを生成するのにシングルクォートを使用していたのを、ダブルクォートを使用するよう修正しています。


Add test case that assigning belongs_to on destroyed object raises frozen error

activerecord/test/cases/associations/belongs_to_associations_test.rbの修正です。

destoy済みのobjectをbelongs_to associationに指定した場合のテストを追加しています。


Update 'rails_welcome.png' to reflect a more diverse population (#32735)

guides/assets/images/getting_started/rails_welcome.pngの修正です。

元々白人(と思われる人)しかいなかったのを、より多様な人種がいる画像に更新しています。

rails_welcome.png

参考:More inclusive imagery


Merge pull request #32617 from tgturner/size-should-use-available-association

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

Associations::CollectionAssociation#size、及び、Associations::CollectionAssociation#empty?メソッドでassociation idsがload済みだった場合、queryを実行せず、そのload済みのidsを使用するよう修正しています。


Ensure that ids_reader respects dirty target whether target is loaded or not

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

ids_readerメソッドで、targetがロード済みかどうかに関わらず、dirty targetを使用するよう修正しています。collection.sizeと挙動を合わせる為。