aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-12 06:18:06 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-12 06:18:06 +0000
commit40d8d38909fe15a96887f4097d95d7323fc93fb7 (patch)
treed0af630d5a983259de0edc350507d3789256a160 /ext
parent38694016bc226abd074c239282dc047ad7c65c55 (diff)
downloadruby-40d8d38909fe15a96887f4097d95d7323fc93fb7.tar.gz
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@15442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/json/lib/json/pure/generator.rb2
-rw-r--r--ext/json/lib/json/pure/parser.rb3
-rw-r--r--ext/openssl/lib/openssl/x509.rb5
-rw-r--r--ext/win32ole/sample/olegen.rb2
4 files changed, 7 insertions, 5 deletions
diff --git a/ext/json/lib/json/pure/generator.rb b/ext/json/lib/json/pure/generator.rb
index 0fe73be41a..c8bbfd09ee 100644
--- a/ext/json/lib/json/pure/generator.rb
+++ b/ext/json/lib/json/pure/generator.rb
@@ -40,7 +40,7 @@ module JSON
# Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
# UTF16 big endian characters as \u????, and return it.
def utf8_to_json(string) # :nodoc:
- string = string.gsub(/["\\\/\x0-\x1f]/) { |c| MAP[c] }
+ string = string.gsub(/["\\\/\x0-\x1f]/) { MAP[$&] }
string.gsub!(/(
(?:
[\xc2-\xdf][\x80-\xbf] |
diff --git a/ext/json/lib/json/pure/parser.rb b/ext/json/lib/json/pure/parser.rb
index e886ba8d2c..39bee54269 100644
--- a/ext/json/lib/json/pure/parser.rb
+++ b/ext/json/lib/json/pure/parser.rb
@@ -122,7 +122,8 @@ module JSON
def parse_string
if scan(STRING)
return '' if self[1].empty?
- self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
+ self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do
+ c = $&
if u = UNESCAPE_MAP[c[1]]
u
else # \uXXXX
diff --git a/ext/openssl/lib/openssl/x509.rb b/ext/openssl/lib/openssl/x509.rb
index e711bda39c..1f81e4d5e6 100644
--- a/ext/openssl/lib/openssl/x509.rb
+++ b/ext/openssl/lib/openssl/x509.rb
@@ -82,7 +82,8 @@ module OpenSSL
def expand_pair(str)
return nil unless str
- return str.gsub(Pair){|pair|
+ return str.gsub(Pair){
+ pair = $&
case pair.size
when 2 then pair[1,1]
when 3 then Integer("0x#{pair[1,2]}").chr
@@ -93,7 +94,7 @@ module OpenSSL
def expand_hexstring(str)
return nil unless str
- der = str.gsub(HexPair){|hex| Integer("0x#{hex}").chr }
+ der = str.gsub(HexPair){$&.to_i(16).chr }
a1 = OpenSSL::ASN1.decode(der)
return a1.value, a1.tag
end
diff --git a/ext/win32ole/sample/olegen.rb b/ext/win32ole/sample/olegen.rb
index 6ef660326f..df6fe7adaa 100644
--- a/ext/win32ole/sample/olegen.rb
+++ b/ext/win32ole/sample/olegen.rb
@@ -230,7 +230,7 @@ class WIN32COMGen
v.visible? && v.variable_kind == 'CONSTANT'
}.each do |v|
io.print " "
- io.print v.name.sub(/^./){|c| c.upcase}
+ io.print v.name.sub(/^./){$&.upcase}
io.print " = "
io.puts v.value
end