summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShota Fukumori (sora_h) <sora134@gmail.com>2010-11-15 10:13:13 +0900
committerFlorian Frank <flori@ping.de>2011-01-02 21:13:43 +0100
commit632804116e13931ffbb41fe4b3916428c911b2c6 (patch)
treefc14c9d73ad3c3ba162c61d2cb695d42cbaf8603 /lib
parente928a2d637560092db6a2f5c40e6e5c982fc87f5 (diff)
downloadjson-632804116e13931ffbb41fe4b3916428c911b2c6.tar.gz
speed up
Diffstat (limited to 'lib')
-rw-r--r--lib/json/common.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb
index 44e659f..13debd1 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -341,11 +341,13 @@ module JSON
end
# Shortuct for iconv.
- def self.iconv(to, from, string)
- if String.method_defined?(:encode)
+ if String.method_defined?(:encode)
+ def self.iconv(to, from, string)
string.encode(to, from)
- else
- require 'iconv'
+ end
+ else
+ require 'iconv'
+ def self.iconv(to, from, string)
Iconv.iconv(to, from, string).first
end
end