From 1340498d2102423665cc5cfe7be7cdba32c72928 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 9 Jun 2019 14:03:31 +0900 Subject: Refactor `disallow_raw_sql!` to avoid `split(/\s*,\s*/)` to order args `split(/\s*,\s*/)` to order args and then `permit.match?` one by one is much slower than `permit.match?` once. --- activerecord/lib/active_record/sanitization.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/sanitization.rb') diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb index 5296499bad..b16cbb0f84 100644 --- a/activerecord/lib/active_record/sanitization.rb +++ b/activerecord/lib/active_record/sanitization.rb @@ -137,8 +137,7 @@ module ActiveRecord def disallow_raw_sql!(args, permit: connection.column_name_matcher) # :nodoc: unexpected = nil args.each do |arg| - next if arg.is_a?(Symbol) || Arel.arel_node?(arg) || - arg.to_s.split(/\s*,\s*/).all? { |part| permit.match?(part) } + next if arg.is_a?(Symbol) || Arel.arel_node?(arg) || permit.match?(arg.to_s) (unexpected ||= []) << arg end -- cgit v1.2.3