mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't dup Strings when jsonifying
This method would be called so many times and would create so many temporary garbage Strings
This commit is contained in:
parent
7d2400ab61
commit
124c082d43
1 changed files with 6 additions and 2 deletions
|
@ -54,9 +54,13 @@ module ActiveSupport
|
||||||
class EscapedString < String #:nodoc:
|
class EscapedString < String #:nodoc:
|
||||||
def to_json(*)
|
def to_json(*)
|
||||||
if Encoding.escape_html_entities_in_json
|
if Encoding.escape_html_entities_in_json
|
||||||
super.gsub ESCAPE_REGEX_WITH_HTML_ENTITIES, ESCAPED_CHARS
|
s = super
|
||||||
|
s.gsub! ESCAPE_REGEX_WITH_HTML_ENTITIES, ESCAPED_CHARS
|
||||||
|
s
|
||||||
else
|
else
|
||||||
super.gsub ESCAPE_REGEX_WITHOUT_HTML_ENTITIES, ESCAPED_CHARS
|
s = super
|
||||||
|
s.gsub! ESCAPE_REGEX_WITHOUT_HTML_ENTITIES, ESCAPED_CHARS
|
||||||
|
s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue