Skip to content

Commit f95e32a

Browse files
authored
Merge pull request #1513 from ahorek/upack1_perf
use unpack1
2 parents 800022a + 1c5599e commit f95e32a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/mail/encodings/quoted_printable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def self.can_encode?(enc)
1616
# Decode the string from Quoted-Printable. Cope with hard line breaks
1717
# that were incorrectly encoded as hex instead of literal CRLF.
1818
def self.decode(str)
19-
::Mail::Utilities.to_lf ::Mail::Utilities.to_crlf(str).gsub(/(?:=0D=0A|=0D|=0A)\r\n/, "\r\n").unpack("M*").first
19+
::Mail::Utilities.to_lf ::Mail::Utilities.to_crlf(str).gsub(/(?:=0D=0A|=0D|=0A)\r\n/, "\r\n").unpack1("M*")
2020
end
2121

2222
def self.encode(str)

lib/mail/encodings/unix_to_unix.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class UnixToUnix < TransferEncoding
55
NAME = "x-uuencode"
66

77
def self.decode(str)
8-
str.sub(/\Abegin \d+ [^\n]*\n/, '').unpack('u').first
8+
str.sub(/\Abegin \d+ [^\n]*\n/, '').unpack1('u')
99
end
1010

1111
def self.encode(str)

lib/mail/utilities.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def Utilities.decode_base64(str)
363363
if !str.end_with?("=") && str.length % 4 != 0
364364
str = str.ljust((str.length + 3) & ~3, "=")
365365
end
366-
str.unpack( 'm' ).first
366+
str.unpack1( 'm' )
367367
end
368368

369369
def Utilities.encode_base64(str)
@@ -399,7 +399,7 @@ def Utilities.encode_utf7(string)
399399
def Utilities.decode_utf7(utf7)
400400
utf7.gsub(/&([^-]+)?-/n) do
401401
if $1
402-
($1.tr(",", "/") + "===").unpack("m")[0].encode(Encoding::UTF_8, Encoding::UTF_16BE)
402+
($1.tr(",", "/") + "===").unpack1("m").encode(Encoding::UTF_8, Encoding::UTF_16BE)
403403
else
404404
"&"
405405
end

0 commit comments

Comments
 (0)