Skip to content

Commit

Permalink
Merge pull request #14521 from kreynolds/replace-regexp-with-include-…
Browse files Browse the repository at this point in the history
…or-string

Replace trivial regexp with string or include, twice as fast
  • Loading branch information
fxn committed Mar 28, 2014
2 parents 74d7df1 + e43cd0a commit 86c53d5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Expand Up @@ -96,7 +96,7 @@ def authenticate(request, &login_procedure)
end end


def user_name_and_password(request) def user_name_and_password(request)
decode_credentials(request).split(/:/, 2) decode_credentials(request).split(':', 2)
end end


def decode_credentials(request) def decode_credentials(request)
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/mime_type.rb
Expand Up @@ -174,7 +174,7 @@ def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], s
end end


def parse(accept_header) def parse(accept_header)
if accept_header !~ /,/ if !accept_header.include?(',')
accept_header = accept_header.split(PARAMETER_SEPARATOR_REGEXP).first accept_header = accept_header.split(PARAMETER_SEPARATOR_REGEXP).first
parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)].compact parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)].compact
else else
Expand Down
Expand Up @@ -318,7 +318,7 @@ def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
def sanitize_limit(limit) def sanitize_limit(limit)
if limit.is_a?(Integer) || limit.is_a?(Arel::Nodes::SqlLiteral) if limit.is_a?(Integer) || limit.is_a?(Arel::Nodes::SqlLiteral)
limit limit
elsif limit.to_s =~ /,/ elsif limit.to_s.include?(',')
Arel.sql limit.to_s.split(',').map{ |i| Integer(i) }.join(',') Arel.sql limit.to_s.split(',').map{ |i| Integer(i) }.join(',')
else else
Integer(limit) Integer(limit)
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/railties/databases.rake
Expand Up @@ -186,7 +186,7 @@ db_namespace = namespace :db do


fixtures_dir = File.join [base_dir, ENV['FIXTURES_DIR']].compact fixtures_dir = File.join [base_dir, ENV['FIXTURES_DIR']].compact


(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir["#{fixtures_dir}/**/*.yml"].map {|f| f[(fixtures_dir.size + 1)..-5] }).each do |fixture_file| (ENV['FIXTURES'] ? ENV['FIXTURES'].split(',') : Dir["#{fixtures_dir}/**/*.yml"].map {|f| f[(fixtures_dir.size + 1)..-5] }).each do |fixture_file|
ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_file) ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_file)
end end
end end
Expand Down

0 comments on commit 86c53d5

Please sign in to comment.