Skip to content

Commit 3473e27

Browse files
authored
Merge pull request #145 from technicalpickles/httheader-content_type-perf
Improve performance of HTTPHeader#content_type
2 parents 705e7c0 + 179976f commit 3473e27

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/net/http/header.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,14 @@ def range_length
699699
# res.content_type # => "application/json"
700700
#
701701
def content_type
702-
return nil unless main_type()
703-
if sub_type()
704-
then "#{main_type()}/#{sub_type()}"
705-
else main_type()
702+
main = main_type()
703+
return nil unless main
704+
705+
sub = sub_type()
706+
if sub
707+
"#{main}/#{sub}"
708+
else
709+
main
706710
end
707711
end
708712

0 commit comments

Comments
 (0)