diff options
Diffstat (limited to 'activesupport/lib/active_support/json/decoding.rb')
-rw-r--r-- | activesupport/lib/active_support/json/decoding.rb | 13 |
1 files changed, 8 insertions, 5 deletions
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 |