brandur / json_schema

A JSON Schema V4 and Hyperschema V4 parser and validator.
MIT License
230 stars 45 forks source link

Reduce empty Array/Hash allocations #114

Closed jhawthorn closed 5 years ago

jhawthorn commented 5 years ago

Instead of allocating new hashes and arrays as default values, this commit reuses the same frozen empty constant. It also short circuits the parse_* methods when they see an empty array/hash.

In our app this takes us from 58441 live objects allocated in this file to 24850.

brandur commented 5 years ago

LGTM. Thanks!

brandur commented 5 years ago

Released as 0.20.6.