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

refactor(walker): use std::ranges:sort instead of std::sort #1267

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/jsonschema/walker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#include <sourcemeta/jsontoolkit/jsonschema.h>
#include <sourcemeta/jsontoolkit/jsonschema_walker.h>

#include <algorithm> // std::max, std::sort
#include <algorithm> // std::max
#include <cassert> // assert
#include <numeric> // std::accumulate
#include <ranges> // std::ranges::sort

auto sourcemeta::jsontoolkit::keyword_priority(
std::string_view keyword, const std::map<std::string, bool> &vocabularies,
Expand Down Expand Up @@ -207,8 +208,8 @@ sourcemeta::jsontoolkit::SchemaKeywordIterator::SchemaKeywordIterator(
}

// Sort keywords based on priority for correct evaluation
std::sort(
this->entries.begin(), this->entries.end(),
std::ranges::sort(
this->entries,
[&vocabularies, &walker](const auto &left, const auto &right) -> bool {
// These cannot be empty or indexes, as we created
// the entries array from a JSON object
Expand Down