Skip to content

Commit

Permalink
Replace trivial regexp with string or include, twice as fast
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelley Reynolds committed Mar 28, 2014
1 parent 38cf00e commit 89a7187
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def authenticate(request, &login_procedure)
end

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

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

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

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)
end
end
Expand Down

0 comments on commit 89a7187

Please sign in to comment.