From 2143027c7f02ced8cfed6a0a0add29d7e3e7d2e4 Mon Sep 17 00:00:00 2001 From: ss Date: Fri, 22 Sep 2023 15:59:39 +0200 Subject: [PATCH 1/4] Fix Clang compiler warnings (#290) --- src/smtp-address-validator.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/smtp-address-validator.cpp b/src/smtp-address-validator.cpp index 14dfae7..5ddd811 100644 --- a/src/smtp-address-validator.cpp +++ b/src/smtp-address-validator.cpp @@ -669,10 +669,6 @@ static const short _address_eof_trans[] = { 1278, 1279, 1280, 1281, 1282, 1283, 0}; static const int address_start = 1; -static const int address_first_final = 196; -static const int address_error = 0; - -static const int address_en_main = 1; bool is_address(const char *p, const char *pe) { From 79535fe0b66e9ae0c64be439153c46f8d1975523 Mon Sep 17 00:00:00 2001 From: Sylvain Joubert Date: Fri, 22 Sep 2023 16:03:55 +0200 Subject: [PATCH 2/4] Fix performance regression from logical combination patch discard (#288) A recent fix to discard patch from invalid logical combination introduced a lot (for large json instance and/or schema) of copies to make a patch backup. On some case, this introduced up to a 100x slower validation time. Resizing the patch object to its previous size avoid unnecessary temporary allocations from the backup object. --- src/json-patch.hpp | 5 ++++- src/json-validator.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/json-patch.hpp b/src/json-patch.hpp index 80fe1df..39a579b 100644 --- a/src/json-patch.hpp +++ b/src/json-patch.hpp @@ -28,10 +28,13 @@ public: json_patch &replace(const json::json_pointer &, json value); json_patch &remove(const json::json_pointer &); + json &get_json() { return j_; } + const json &get_json() const { return j_; } + operator json() const { return j_; } private: - json j_; + json j_ = nlohmann::json::array(); static void validateJsonPatch(json const &patch); }; diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 77d701f..6ede7c8 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -436,12 +436,12 @@ class logical_combination : public schema for (auto &s : subschemata_) { first_error_handler esub; - json_patch old_patch(patch); + auto oldPatchSize = patch.get_json().size(); s->validate(ptr, instance, patch, esub); if (!esub) count++; else - patch = old_patch; + patch.get_json().get_ref().resize(oldPatchSize); if (is_validate_complete(instance, ptr, e, esub, count)) return; From 0be4d4c4b53a814f20e162418de5070e14c792bd Mon Sep 17 00:00:00 2001 From: andrejlevkovitch Date: Fri, 22 Sep 2023 16:12:57 +0200 Subject: [PATCH 3/4] do not fetch nlohmann_json if it already added in main project (#287) --- CMakeLists.txt | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b81049..02a2dae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,26 +80,28 @@ endif () ]==============================================================================================] set(fetch_packages "") -# Fetch/Find nlohmann_json -# TODO: Remove when bumping cmake >= 3.24 -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) - FetchContent_Declare(nlohmann_json - GIT_REPOSITORY https://github.com/nlohmann/json - GIT_TAG ${JSON_FETCH_VERSION} - FIND_PACKAGE_ARGS - ) - list(APPEND fetch_packages nlohmann_json) -else () - # Try to get system installed version - find_package(nlohmann_json QUIET) - if (NOT nlohmann_json_FOUND) - # If failed fetch the desired version - FetchContent_Declare(nlohmann_json - GIT_REPOSITORY https://github.com/nlohmann/json - GIT_TAG ${JSON_FETCH_VERSION} - ) - list(APPEND fetch_packages nlohmann_json) - endif () +if (NOT TARGET nlohmann_json) + # Fetch/Find nlohmann_json + # TODO: Remove when bumping cmake >= 3.24 + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + FetchContent_Declare(nlohmann_json + GIT_REPOSITORY https://github.com/nlohmann/json + GIT_TAG ${JSON_FETCH_VERSION} + FIND_PACKAGE_ARGS + ) + list(APPEND fetch_packages nlohmann_json) + else () + # Try to get system installed version + find_package(nlohmann_json QUIET) + if (NOT nlohmann_json_FOUND) + # If failed fetch the desired version + FetchContent_Declare(nlohmann_json + GIT_REPOSITORY https://github.com/nlohmann/json + GIT_TAG ${JSON_FETCH_VERSION} + ) + list(APPEND fetch_packages nlohmann_json) + endif () + endif () endif () # Handle configure flags From c6fefb80fb34ed9c44664cbf7582f8caee452824 Mon Sep 17 00:00:00 2001 From: GerritNG <124732275+GerritNG@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:55:19 -0600 Subject: [PATCH 4/4] Update README.md (#301) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9b80ed..93751e7 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ types, depending on if the schema type is "integer" or "number". Bignum This library is based on Niels Lohmann's JSON-library and thus has a build-dependency to it. -Currently at least version **3.6.0** of NLohmann's JSON library +Currently at least version **3.8.0** of NLohmann's JSON library is required. Various methods using CMake can be used to build this project.