From 5aa55903a6c20a0989723bf2f84f8932da3a85e4 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 12 Feb 2008 06:18:06 +0000 Subject: * ext/json/lib/json/pure/generator.rb, ext/json/lib/json/pure/parser.rb, ext/openssl/lib/openssl/x509.rb, ext/win32ole/sample/olegen.rb, lib/date/format.rb, lib/irb/context.rb, lib/irb/workspace.rb, lib/net/http.rb, lib/net/imap.rb, lib/rdoc/generator.rb, lib/rdoc/markup/to_html.rb, lib/rdoc/markup/to_latex.rb, lib/rdoc/parsers/parse_c.rb, lib/rdoc/ri/formatter.rb, lib/rexml/parsers/baseparser.rb, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rss/parser.rb, lib/uri/common.rb, lib/uri/generic.rb, lib/webrick/httpresponse.rb, lib/webrick/httpservlet/filehandler.rb, lib/yaml/baseemitter.rb, lib/yaml/encoding.rb: performance tuning arround String#gsub. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/http.rb | 2 +- lib/net/imap.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/net') diff --git a/lib/net/http.rb b/lib/net/http.rb index 06b176b3c..d3e3d9f2f 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1521,7 +1521,7 @@ module Net #:nodoc: private :encode_kvpair def urlencode(str) - str.gsub(/[^a-zA-Z0-9_\.\-]/n) {|s| sprintf('%%%02x', s[0]) } + str.gsub(/[^a-zA-Z0-9_\.\-]/n) { sprintf('%%%02x', $&[0]) } end private :urlencode diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 394f0d989..016f567b0 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -857,11 +857,11 @@ module Net # Encode a string from UTF-8 format to modified UTF-7. def self.encode_utf7(s) - return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) { |x| + return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) { if $1 "&-" else - base64 = [x.unpack("U*").pack("n*")].pack("m") + base64 = [$&.unpack("U*").pack("n*")].pack("m") "&" + base64.delete("=\n").tr("/", ",") + "-" end }.force_encoding("ASCII-8BIT") -- cgit