From 7ca5c37f484edebd169e4136331500d4b5c31cbe Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 21 Jul 2017 09:23:24 -0400 Subject: Ensure `ToSql` collector returns a UTF-8 string Switching from `''.dup` to `String.new` had the side effect of changing the encoding on Ruby 2.4 and later. Oddly, `String.new(encoding: Encoding::UTF_8)` is significantly slower than `''.dup`. This seems like a bug in Ruby, but not something we're going to address right now. A test has been added to ensure this regression doesn't occur again. --- lib/arel/collectors/plain_string.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/arel/collectors/plain_string.rb b/lib/arel/collectors/plain_string.rb index 4c8c15cc9c..1e8d2a2152 100644 --- a/lib/arel/collectors/plain_string.rb +++ b/lib/arel/collectors/plain_string.rb @@ -3,7 +3,7 @@ module Arel module Collectors class PlainString def initialize - @str = String.new + @str = ''.dup end def value -- cgit v1.2.3