From a0613ad8a9773c76a9b0a256f7099fde35823674 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 5 Oct 2012 12:07:16 -0300 Subject: Revert "Use flat_map { } instead of map {}.flatten" This reverts commit abf8de85519141496a6773310964ec03f6106f3f. We should take a deeper look to those cases flat_map doesn't do deep flattening. irb(main):002:0> [[[1,3], [1,2]]].map{|i| i}.flatten => [1, 3, 1, 2] irb(main):003:0> [[[1,3], [1,2]]].flat_map{|i| i} => [[1, 3], [1, 2]] --- activesupport/lib/active_support/multibyte/unicode.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index d7a403c45b..f49ca47f14 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -219,9 +219,9 @@ module ActiveSupport # encoding is entirely CP1252 or ISO-8859-1. def tidy_bytes(string, force = false) if force - return string.unpack("C*").flat_map do |b| + return string.unpack("C*").map do |b| tidy_byte(b) - end.compact.pack("C*").unpack("U*").pack("U*") + end.flatten.compact.pack("C*").unpack("U*").pack("U*") end bytes = string.unpack("C*") -- cgit v1.2.3