Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(ajv): reuse compiled schema #714

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matthiasschwarz
Copy link

Moved initialization of Ajv, ajvErrors and the creation of the adjusted schema outside of the Resolver to allow the instance of Ajv to reuse the compiled schema on multiple invocations of the Resolver. Also adjusted the example usage in the README to show that the ajvResolver should only be called once for the schema.

This aligns with the recommended approach of compiling a schema only once as described in the docs under Managing schemas.

Overall this should also significantly reduce the memory footprint since the instance of Ajv and the modified schema is reused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant