A recent fix to discard patch from invalid logical combination introduced a lot (for large json instance and/or schema) of copies to make a patch backup. On some case, this introduced up to a 100x slower validation time (I observed times from 50ms to 7s on one of my use case).
Resizing the patch object to its previous size avoid unnecessary temporary allocations from the backup object.
I needed to expose the internal json object to be able to resize it. I'm not sure how differently we could achieve this if you don't like that.
It also fixes the default value of an empty json_patch. I think it should be an empty array and not a null json according to the json patch schema.
I know you mentioned in #229 that you won't accept more changes on this subject, however this is quite a big performance regression so I hope this can still be merged.
On that matter, I'm willing to spend a bit of time, after this fix, on the subject if you have ideas on how to better integrate the default values handling in the library. I think this is quite an important feature as it makes parsing a lot easier if one can put default values in a single reference place (the schema). I don't known what elements you don't like in the current design though.
A recent fix to discard patch from invalid logical combination introduced a lot (for large json instance and/or schema) of copies to make a patch backup. On some case, this introduced up to a 100x slower validation time (I observed times from 50ms to 7s on one of my use case).
Resizing the patch object to its previous size avoid unnecessary temporary allocations from the backup object.