Skip to content

Commit 0060524

Browse files
etiennebarriebyroot
andcommitted
Skip one allocation when there are no JSON options
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
1 parent 9a470a2 commit 0060524

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activesupport/lib/active_support/json/encoding.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class << self
4444
# ActiveSupport::JSON.encode({ key: "\u2028<>&" }, html_safe: false)
4545
# # => "{\"key\":\"\u2028<>&\"}"
4646
def encode(value, options = nil)
47-
if options.nil?
47+
if options.nil? || options.empty?
4848
Encoding.encode_without_options(value)
4949
else
5050
Encoding.json_encoder.new(options).encode(value)

0 commit comments

Comments
 (0)