Permalink
Browse files

Headers parsing performance optimization

  • Loading branch information...
1 parent 47e288e commit bced96df272d4c22d7ee64349d72983e2b17f0ca @bogdan bogdan committed Mar 6, 2012
Showing with 3 additions and 5 deletions.
  1. +1 −1 lib/mail/fields/common/common_field.rb
  2. +2 −4 lib/mail/header.rb
@@ -34,7 +34,7 @@ def field_length
end
def responsible_for?( val )
- name.to_s.downcase == val.to_s.downcase
+ name.to_s.casecmp(val.to_s) == 0
end
private
View
@@ -78,9 +78,7 @@ def fields=(unfolded_fields)
field = Field.new(field, nil, charset)
field.errors.each { |error| self.errors << error }
- selected = select_field_for(field.name)
-
- if selected.any? && limited_field?(field.name)
+ if limited_field?(field.name) && (selected = select_field_for(field.name)) && selected.any?
selected.first.update(field.name, field.value)
else
@fields << field
@@ -254,7 +252,7 @@ def split_header
end
def select_field_for(name)
- fields.select { |f| f.responsible_for?(name.to_s) }
+ fields.select { |f| f.responsible_for?(name) }
end
def limited_field?(name)

0 comments on commit bced96d

Please sign in to comment.