Skip to content
  • John Hawthorn's avatar
    66db6743
    Avoid extra pass on AS::JSON.dump with no options · 66db6743
    John Hawthorn authored
    JSONGemEncoder.encode previously would always perform two passes. First
    it would call `.as_json(options)`, but then would perform a second pass
    "jsonify" to recursively call `.as_json` (this time without options)
    until the data converges into a "JSON-ready" representation.
    
    When options are not given, the second pass should be equivalent to the
    first, so we can detect that, and only perform the "jsonify" step.
    
    The only user-visible effect of this should be that we will pass no
    options to `as_json` instead of an empty Hash, but implementations of
    `as_json` should already be expected to accept that.
    66db6743
    Avoid extra pass on AS::JSON.dump with no options
    John Hawthorn authored
    JSONGemEncoder.encode previously would always perform two passes. First
    it would call `.as_json(options)`, but then would perform a second pass
    "jsonify" to recursively call `.as_json` (this time without options)
    until the data converges into a "JSON-ready" representation.
    
    When options are not given, the second pass should be equivalent to the
    first, so we can detect that, and only perform the "jsonify" step.
    
    The only user-visible effect of this should be that we will pass no
    options to `as_json` instead of an empty Hash, but implementations of
    `as_json` should already be expected to accept that.
Loading