From 3eef3d38cf91721870413ae34eb6b8efde33106e Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 30 Oct 2024 15:20:01 +0100 Subject: [PATCH] Skip calling configure if there are no options * Set all defaults in the constructor. * Order the instance variables in the same order as in #configure. --- lib/json/pure/generator.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb index 8df1692d0..42491bfd8 100644 --- a/lib/json/pure/generator.rb +++ b/lib/json/pure/generator.rb @@ -142,10 +142,12 @@ def initialize(opts = nil) @array_nl = '' @allow_nan = false @ascii_only = false - @script_safe = false - @strict = false + @depth = 0 @buffer_initial_length = 1024 - configure(opts || {}) + @script_safe = false + @strict = false + @max_nesting = 100 + configure(opts) if opts end # This string is used to indent levels in the JSON text.