なるようになるブログ

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

rails commit log流し読み(2016/04/30)

2016/04/30分のコミットです。

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


Document config.assets.gzip flag. Follow up of https://github.com/rails/sprockets-rails/pull/342.

rails guideのThe Asset PipelineConfiguring Rails Applicationsの修正です。

コンパイル済みassetsのgzip版を作成するかどうかを指定する為のconfig(config.assets.gzip)についての説明を追加しています。デフォルトはtrueで、gzip版を作成したくない場合は、config.assets.gzipにfalseを指定すると、作成されません。


Fix typos in asset_pipeline.md [ci skip]

rails guideのThe Asset Pipelineの修正です。

Serving GZipped version of assetsの項で、datadateにタイポしていたのを修正しています。


Consistent spelling of "gzipped" [ci skip]

rails guideのConfiguring Rails Applicationsの修正です。

gzippedgzipedにタイポしている箇所があったのを修正しています。


Update configuring.md with colons and periods

rails guideのConfiguring Rails Applicationsの修正です。

各項目名の最後に区切りがわかりやすくなるようコロンを追加、及び終端にピリオドが無い箇所があったのを追加しています。


AS::Duration changelog polish

activesupport/CHANGELOG.mdの修正です。

ActiveSupport::Durationでweeksとhoursを使用出来るよう修正した対応のentryについて、最初コミットされた際に記載された内容に修正しています。そちらの方がユーザに意図が伝わりやすい為、ですかねえ。


Chomp: prefer String#chomp where we can for a clarity boost

activejob/test/support/integration/test_case_helpers.rbactivemodel/lib/active_model/validations/acceptance.rbactivemodel/lib/active_model/validator.rbの修正です。

文字列を除去するのに#gsubを使ったり、#[]を使ったりしていたのを、String#chompを使用するよう修正しています。


restores the regexp used in String#blank?

activesupport/lib/active_support/core_ext/object/blank.rbの修正です。

Speed up String#blank? Regex で行った正規表現の修正を元に戻しています。

class String
+  BLANK_RE = /\A[[:space:]]*\z/
+
   # A string is blank if it's empty or contains whitespaces only:
   #
   #   ''.blank?       # => true
@@ -113,10 +115,7 @@ def blank?
     # The regexp that matches blank strings is expensive. For the case of empty
     # strings we can speed up this method (~3.5x) with an empty? call. The
     # penalty for the rest of strings is marginal.
-    #
-    # Double negation in the second operand is also a performance tweak, it is
-    # faster than the positive \A[[:space:]]*\z.
-    empty? || !(/[[:^space:]]/ === self)
+    empty? || BLANK_RE === self
   end

色々調査したり性能調査した結果、早くなるとは言い切れない為との事です。議論及び各種ベンチマークは元のPR(Speed up String#blank? Regex by schneems · Pull Request #24658 · rails/rails)にありますので、詳細はそちらを参照。


Migrations: move version-finding responsibility

activerecord/lib/active_record/migration.rbactiverecord/lib/active_record/migration/compatibility.rbの修正です。

Migration.[]で行っていたmigration versionの取得処理を、ActiveRecord::Migration::Compatibility.findメソッドに移動しています。Compatibility moduleで行うのが適切だろう、との事で。


Treat blank comments as no comment for indexes

activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rbactiverecord/lib/active_record/connection_adapters/postgresql_adapter.rbの修正です。

index生成処理で、値が空の場合にcommentを生成しないよう修正しています。


Extract add_sql_comment! method

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rbactiverecord/lib/active_record/connection_adapters/mysql/schema_creation.rbの修正です。

comment用SQLの追加処理を#add_sql_comment!メソッドに切り出しています。


rm unused require

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

使用していないthreadのrequireを削除しています。


add #24385 to 5.0 release notes [ci skip]

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

datetime_fielddatetime_field_tagをdeprecateにした、Deprecate datetime_field and datetime_field_tag helpers. by morgoth · Pull Request #24385 · rails/railsの対応について、release noteにentryを追加しています。