From 9e2536393e9a41f53bf543d0ea39a16b96e9bc17 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Fri, 28 Dec 2007 18:37:17 +0000 Subject: 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 --- activesupport/lib/active_support/json/decoding.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'activesupport/lib/active_support/json/decoding.rb') 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 -- cgit v1.2.3