From 2e8fe96422287b3b239a4cdd849d95933b0fd555 Mon Sep 17 00:00:00 2001 From: Sven Fink Date: Mon, 10 Feb 2020 10:58:11 +0100 Subject: [PATCH] Avoid copy of json on set_root_schema If a json object containing a schema is moved into the json validator it should not be copied. At least the public interface of the validator class schould not force the copy. --- src/json-validator.cpp | 5 +++++ src/nlohmann/json-schema.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 96fa626..8fc4b5a 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -1150,6 +1150,11 @@ void json_validator::set_root_schema(const json &schema) root_->set_root_schema(schema); } +void json_validator::set_root_schema(json &&schema) +{ + root_->set_root_schema(std::move(schema)); +} + void json_validator::validate(const json &instance) const { throwing_error_handler err; diff --git a/src/nlohmann/json-schema.hpp b/src/nlohmann/json-schema.hpp index 204f412..d6e0ede 100644 --- a/src/nlohmann/json-schema.hpp +++ b/src/nlohmann/json-schema.hpp @@ -176,6 +176,7 @@ public: // insert and set the root-schema void set_root_schema(const json &); + void set_root_schema(json &&); // validate a json-document based on the root-schema void validate(const json &) const;