ruby-json-schema/json-schema — pull request #182 by pd (2014-11-22 21:52:45+00:00)
Title: Caching inner schemas

:warning: :construction: :warning:

I've been working on using json-schema to validate all incoming JSON data for an API I'm writing; it's functional, but can be pretty slow for complex endpoints (50ms+). I did some profiling to narrow it down to hitting `JSON::Schema#initialize` *a lot*. The change in #180 helped a bit, but the core problem remains that we constantly re-create Schema instances.

I plan to add either `Schema#inner_schemas['#/some/path/fragment']`, or even just directly register them into `JSON::Validator.schemas`; the various `Attribute` validation classes can then fetch from that, and only create a new schema on miss.

The code in this PR adds rspec for now, only because I couldn't come up with any more reasonable means of testing this right now. I've not touched `lib` at all yet.