aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-12-28 18:37:17 +0000
committerRick Olson <technoweenie@gmail.com>2007-12-28 18:37:17 +0000
commit9e2536393e9a41f53bf543d0ea39a16b96e9bc17 (patch)
tree0935676c8fb7017f77ee3fbbbd50b8d70fcff56b
parent0e3a54a3b92c0f9a7bf95f8cb11ba2db89f6eecc (diff)
downloadrails-9e2536393e9a41f53bf543d0ea39a16b96e9bc17.tar.gz
rails-9e2536393e9a41f53bf543d0ea39a16b96e9bc17.tar.bz2
rails-9e2536393e9a41f53bf543d0ea39a16b96e9bc17.zip
remove multiple enumerations from ActiveSupport::JSON#convert_json_to_yaml when dealing with date/time values. [rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8505 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/json/decoding.rb13
2 files changed, 10 insertions, 5 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 7252262d6a..81eeb92e32 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* remove multiple enumerations from ActiveSupport::JSON#convert_json_to_yaml when dealing with date/time values. [rick]
+
* Hash#symbolize_keys skips keys that can't be symbolized. #10500 [Brad Greenlee]
* Ruby 1.9 compatibility. #1689, #10466, #10468, #10554 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink]
diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb
index f24aa9e57c..c58001f49f 100644
--- a/activesupport/lib/active_support/json/decoding.rb
+++ b/activesupport/lib/active_support/json/decoding.rb
@@ -45,11 +45,14 @@ module ActiveSupport
if marks.empty?
json.gsub(/\\\//, '/')
else
- # FIXME: multiple slow enumerations
- output = ([0] + marks.map(&:succ)).
- zip(marks + [json.length]).
- map { |left, right| json[left..right] }.
- join(" ")
+ left_pos = [-1].push(*marks)
+ right_pos = marks << json.length
+ output = []
+ left_pos.each_with_index do |left, i|
+ output << json[left.succ..right_pos[i]]
+ end
+ output = output * " "
+
times.each { |i| output[i-1] = ' ' }
output.gsub!(/\\\//, '/')
output