Skip to content

Commit

Permalink
Re-use the JSON Toolkit EvaluationContext across runs
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Sep 25, 2024
1 parent 89b721a commit 2f2077f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion implementations/jsontoolkit/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ int validate(const std::filesystem::path &example) {
sourcemeta::jsontoolkit::official_resolver,
sourcemeta::jsontoolkit::default_schema_compiler)};

sourcemeta::jsontoolkit::EvaluationContext context;
const auto timestamp_start{std::chrono::high_resolution_clock::now()};

auto num = 0;
for (const auto &instance : instances) {
context.prepare(instance);
num += 1;
const auto result{
sourcemeta::jsontoolkit::evaluate(schema_template, instance)};
sourcemeta::jsontoolkit::evaluate(schema_template, context)};
if (!result) {
std::cerr << "Error validating instance " << num << "\n";
return EXIT_FAILURE;
Expand Down

0 comments on commit 2f2077f

Please sign in to comment.