1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Preemptively freeze more Strings on normalize to ensure that we don't create unnecessary copies

This commit is contained in:
Holger Just 2017-08-02 19:58:25 +02:00
parent ab7331a7a9
commit 65e272347d
2 changed files with 3 additions and 3 deletions

View File

@ -143,11 +143,11 @@ module Rackstash
when ::Date
return value.iso8601.encode!(Encoding::UTF_8).freeze
when ::Regexp, ::Range, ::URI::Generic, ::Pathname
return utf8_encode(value)
return utf8_encode(value.to_s.freeze)
when Exception
exception = "#{value.message} (#{value.class})"
exception = [exception, *value.backtrace].join("\n") if value.backtrace
return utf8_encode(exception)
return utf8_encode(exception.freeze)
when ::Proc
return normalize(value, scope: scope, wrap: wrap)
when ::BigDecimal

View File

@ -76,7 +76,7 @@ module Rackstash
value.flatten!
value
else
utf8_encode(value).strip.freeze
utf8_encode(value.to_s.strip.freeze)
end
end
end