Make Symbol#to_s return frozen string.
Monkey-patch Symbol#to_s to return a frozen (immutable) string instead of a mutable string. This should reduce string allocations, and thereby reduce memory usage and garbage collector pressure, but it may be incompatible with libraries that expect Symbol#to_s to return a mutable string. https://bugs.ruby-lang.org/issues/16150 https://github.com/Shopify/symbol-fstring
This commit is contained in:
@@ -62,3 +62,10 @@ end
|
||||
class String
|
||||
include Danbooru::Extensions::String
|
||||
end
|
||||
|
||||
# Make Symbol#to_s return a frozen string. This reduces allocations, but may be
|
||||
# incompatible with some libraries.
|
||||
#
|
||||
# https://bugs.ruby-lang.org/issues/16150
|
||||
# https://github.com/Shopify/symbol-fstring
|
||||
Symbol.alias_method(:to_s, :name)
|
||||
|
||||
Reference in New Issue
Block a user