lib/active_support/json/decoding.rb in activesupport-2.0.2 vs lib/active_support/json/decoding.rb in activesupport-2.0.4
- old
+ new
@@ -43,14 +43,17 @@
end
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
end
end