notEthan / jsi

JSI: JSON Schema Instantiation in Ruby
Other
22 stars 1 forks source link

Base mutation #204

Closed notEthan closed 2 years ago

notEthan commented 2 years ago

child instances' schemas would not be recalculated when the instance was mutated. comparing the memomap result inputs by equality, no change is detected as the mutation applies to the memo inputs the same as the instance - obviously, since they're the same object.

so, store the hash of the inputs as well as the inputs, and compare both. (comparing just the hash would have a possibility of collision.) this is a bit expensive and significantly impacts performance.

there's a minuscule chance that modified inputs have a hash collision (same hash before and after modification) and no change is detected. I'd rather have memomap result inputs store a frozen copy, but that's much more expensive still, and the chance of collision is probably negligible.