Compare commits

...

5 Commits

Author SHA1 Message Date
Daniel Lemire 933c2ebeac Preparing release 2022-07-28 21:46:45 -04:00
Daniel Lemire db3e813aa6 Verifying and fixing issue 1876 (#1877)
* Verifying and fixing issue 1876

* Typo
2022-07-28 21:45:54 -04:00
Daniel Lemire 9c95a48fe6 cleaning on-demand benchmarks (#1875)
* Setting RapidJSON and yyjson to their latest version.

* Let us stop dumping all of the benchmarks (it is confusing) on screen.
2022-07-28 20:28:29 -04:00
Daniel Lemire cb20f7e7df Update CONTRIBUTING.md 2022-07-20 09:46:52 -04:00
Dirk Stolle 18b9168eec remove empty if block (#1873)
I guess it will be thrown away by the compiler's optimizer
anyway, but there is no need to keep this in the code.
2022-07-19 20:36:51 -04:00
29 changed files with 253 additions and 142 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14)
project( project(
simdjson simdjson
# The version number is modified by tools/release.py # The version number is modified by tools/release.py
VERSION 2.2.1 VERSION 2.2.2
DESCRIPTION "Parsing gigabytes of JSON per second" DESCRIPTION "Parsing gigabytes of JSON per second"
HOMEPAGE_URL "https://simdjson.org/" HOMEPAGE_URL "https://simdjson.org/"
LANGUAGES CXX C LANGUAGES CXX C
+1 -1
View File
@@ -54,7 +54,7 @@ Contributors are encouraged to :
- Document their changes. Though we do not enforce a rule regarding code comments, we prefer that non-trivial algorithms and techniques be somewhat documented in the code. - Document their changes. Though we do not enforce a rule regarding code comments, we prefer that non-trivial algorithms and techniques be somewhat documented in the code.
- Follow as much as possible the existing code style. We do not enforce a specific code style, but we prefer consistency. - Follow as much as possible the existing code style. We do not enforce a specific code style, but we prefer consistency.
- Modify as few lines of code as possible when working on an issue. The more lines you modify, the harder it is for your fellow human beings to understand what is going on. - Modify as few lines of code as possible when working on an issue. The more lines you modify, the harder it is for your fellow human beings to understand what is going on.
- Tools may report "problems" with the code, but we never delegate programming to tools: if there is a problem with the code, we need to understand it. Thus we will not "fix" code merely to please a static analyzer if we do not understand. - Tools may report "problems" with the code, but we never delegate programming to tools: if there is a problem with the code, we need to understand it. Thus we will not "fix" code merely to please a static analyzer.
- Provide tests for any new feature. We will not merge a new feature without tests. - Provide tests for any new feature. We will not merge a new feature without tests.
Pull Requests Pull Requests
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = simdjson
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = "2.2.1" PROJECT_NUMBER = "2.2.2"
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a
+101 -59
View File
@@ -25,74 +25,116 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
SIMDJSON_POP_DISABLE_WARNINGS SIMDJSON_POP_DISABLE_WARNINGS
#include "json2msgpack/simdjson_dom.h"
#include "json2msgpack/simdjson_ondemand.h" #include "json2msgpack/simdjson_ondemand.h"
#include "json2msgpack/rapidjson.h" #include "json2msgpack/simdjson_dom.h"
#include "json2msgpack/yyjson.h" #include "json2msgpack/yyjson.h"
#include "json2msgpack/rapidjson.h"
#if SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "json2msgpack/sajson.h" #include "json2msgpack/sajson.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "json2msgpack/nlohmann_json.h" #include "json2msgpack/nlohmann_json.h"
#include "partial_tweets/simdjson_ondemand.h"
#include "partial_tweets/simdjson_dom.h"
#include "partial_tweets/yyjson.h"
#if SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "partial_tweets/sajson.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "partial_tweets/rapidjson.h"
#if SIMDJSON_COMPETITION_SAX
#include "partial_tweets/rapidjson_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "partial_tweets/nlohmann_json.h"
#if SIMDJSON_COMPETITION_SAX
#include "partial_tweets/nlohmann_json_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "distinct_user_id/simdjson_ondemand.h"
#include "distinct_user_id/simdjson_ondemand_json_pointer.h"
#include "distinct_user_id/simdjson_dom.h"
#include "distinct_user_id/simdjson_dom_json_pointer.h"
#include "distinct_user_id/yyjson.h"
#if SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "distinct_user_id/sajson.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "distinct_user_id/rapidjson.h"
#if SIMDJSON_COMPETITION_SAX
#include "distinct_user_id/rapidjson_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "distinct_user_id/nlohmann_json.h"
#if SIMDJSON_COMPETITION_SAX
#include "distinct_user_id/nlohmann_json_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "find_tweet/simdjson_ondemand.h"
#include "find_tweet/simdjson_dom.h"
#include "find_tweet/yyjson.h"
#if SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "find_tweet/sajson.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "find_tweet/rapidjson.h"
#if SIMDJSON_COMPETITION_SAX
#include "find_tweet/rapidjson_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "find_tweet/nlohmann_json.h"
#if SIMDJSON_COMPETITION_SAX
#include "find_tweet/nlohmann_json_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "top_tweet/simdjson_ondemand.h"
#include "top_tweet/simdjson_dom.h"
#include "top_tweet/yyjson.h"
#if SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "top_tweet/sajson.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "top_tweet/rapidjson.h"
#if SIMDJSON_COMPETITION_SAX
#include "top_tweet/rapidjson_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "top_tweet/nlohmann_json.h"
#if SIMDJSON_COMPETITION_SAX
#include "top_tweet/nlohmann_json_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "kostya/simdjson_ondemand.h"
#include "kostya/simdjson_dom.h"
#include "kostya/yyjson.h"
#if SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "kostya/sajson.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "kostya/rapidjson.h"
#if SIMDJSON_COMPETITION_SAX
#include "kostya/rapidjson_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "kostya/nlohmann_json.h"
#if SIMDJSON_COMPETITION_SAX
#include "kostya/nlohmann_json_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "large_random/simdjson_ondemand.h"
#if SIMDJSON_COMPETITION_ONDEMAND_UNORDERED
#include "large_random/simdjson_ondemand_unordered.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_UNORDERED
#include "large_random/simdjson_dom.h"
#include "large_random/yyjson.h"
#if SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "large_random/sajson.h"
#endif // SIMDJSON_COMPETITION_ONDEMAND_SAJSON
#include "large_random/rapidjson.h"
#if SIMDJSON_COMPETITION_SAX
#include "large_random/rapidjson_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "large_random/nlohmann_json.h"
#if SIMDJSON_COMPETITION_SAX
#include "large_random/nlohmann_json_sax.h"
#endif // SIMDJSON_COMPETITION_SAX
#include "amazon_cellphones/simdjson_dom.h" #include "amazon_cellphones/simdjson_dom.h"
#include "amazon_cellphones/simdjson_ondemand.h" #include "amazon_cellphones/simdjson_ondemand.h"
#include "large_amazon_cellphones/simdjson_dom.h" #include "large_amazon_cellphones/simdjson_dom.h"
#include "large_amazon_cellphones/simdjson_ondemand.h" #include "large_amazon_cellphones/simdjson_ondemand.h"
#include "partial_tweets/simdjson_dom.h"
#include "partial_tweets/simdjson_ondemand.h"
#include "partial_tweets/yyjson.h"
#include "partial_tweets/sajson.h"
#include "partial_tweets/rapidjson.h"
#include "partial_tweets/rapidjson_sax.h"
#include "partial_tweets/nlohmann_json.h"
#include "partial_tweets/nlohmann_json_sax.h"
#include "large_random/simdjson_dom.h"
#include "large_random/simdjson_ondemand.h"
#include "large_random/simdjson_ondemand_unordered.h"
#include "large_random/yyjson.h"
#include "large_random/sajson.h"
#include "large_random/rapidjson.h"
#include "large_random/rapidjson_sax.h"
#include "large_random/nlohmann_json.h"
#include "large_random/nlohmann_json_sax.h"
#include "kostya/simdjson_dom.h"
#include "kostya/simdjson_ondemand.h"
#include "kostya/yyjson.h"
#include "kostya/sajson.h"
#include "kostya/rapidjson.h"
#include "kostya/rapidjson_sax.h"
#include "kostya/nlohmann_json.h"
#include "kostya/nlohmann_json_sax.h"
#include "distinct_user_id/simdjson_dom.h"
#include "distinct_user_id/simdjson_dom_json_pointer.h"
#include "distinct_user_id/simdjson_ondemand.h"
#include "distinct_user_id/simdjson_ondemand_json_pointer.h"
#include "distinct_user_id/yyjson.h"
#include "distinct_user_id/sajson.h"
#include "distinct_user_id/rapidjson.h"
#include "distinct_user_id/rapidjson_sax.h"
#include "distinct_user_id/nlohmann_json.h"
#include "distinct_user_id/nlohmann_json_sax.h"
#include "find_tweet/simdjson_dom.h"
#include "find_tweet/simdjson_ondemand.h"
#include "find_tweet/yyjson.h"
#include "find_tweet/sajson.h"
#include "find_tweet/rapidjson.h"
#include "find_tweet/rapidjson_sax.h"
#include "find_tweet/nlohmann_json.h"
#include "find_tweet/nlohmann_json_sax.h"
#include "top_tweet/simdjson_dom.h"
#include "top_tweet/simdjson_ondemand.h"
#include "top_tweet/yyjson.h"
#include "top_tweet/sajson.h"
#include "top_tweet/rapidjson.h"
#include "top_tweet/rapidjson_sax.h"
#include "top_tweet/nlohmann_json.h"
#include "top_tweet/nlohmann_json_sax.h"
BENCHMARK_MAIN(); BENCHMARK_MAIN();
+2 -1
View File
@@ -46,13 +46,14 @@ struct rapidjson : rapidjson_base {
}; };
BENCHMARK_TEMPLATE(distinct_user_id, rapidjson)->UseManualTime(); BENCHMARK_TEMPLATE(distinct_user_id, rapidjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct rapidjson_insitu : rapidjson_base { struct rapidjson_insitu : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) { bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) {
return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result); return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(distinct_user_id, rapidjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(distinct_user_id, rapidjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace partial_tweets } // namespace partial_tweets
#endif // SIMDJSON_COMPETITION_RAPIDJSON #endif // SIMDJSON_COMPETITION_RAPIDJSON
+2 -1
View File
@@ -49,13 +49,14 @@ struct yyjson : yyjson_base {
}; };
BENCHMARK_TEMPLATE(distinct_user_id, yyjson)->UseManualTime(); BENCHMARK_TEMPLATE(distinct_user_id, yyjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct yyjson_insitu : yyjson_base { struct yyjson_insitu : yyjson_base {
bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) { bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) {
return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result); return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result);
} }
}; };
BENCHMARK_TEMPLATE(distinct_user_id, yyjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(distinct_user_id, yyjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace distinct_user_id } // namespace distinct_user_id
#endif // SIMDJSON_COMPETITION_YYJSON #endif // SIMDJSON_COMPETITION_YYJSON
+2 -1
View File
@@ -40,13 +40,14 @@ struct rapidjson : rapidjson_base {
}; };
BENCHMARK_TEMPLATE(find_tweet, rapidjson)->UseManualTime(); BENCHMARK_TEMPLATE(find_tweet, rapidjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct rapidjson_insitu : rapidjson_base { struct rapidjson_insitu : rapidjson_base {
bool run(simdjson::padded_string &json, uint64_t find_id, std::string_view &result) { bool run(simdjson::padded_string &json, uint64_t find_id, std::string_view &result) {
return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), find_id, result); return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), find_id, result);
} }
}; };
BENCHMARK_TEMPLATE(find_tweet, rapidjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(find_tweet, rapidjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace find_tweet } // namespace find_tweet
#endif // SIMDJSON_COMPETITION_RAPIDJSON #endif // SIMDJSON_COMPETITION_RAPIDJSON
+2 -2
View File
@@ -40,14 +40,14 @@ struct yyjson : yyjson_base {
} }
}; };
BENCHMARK_TEMPLATE(find_tweet, yyjson)->UseManualTime(); BENCHMARK_TEMPLATE(find_tweet, yyjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct yyjson_insitu : yyjson_base { struct yyjson_insitu : yyjson_base {
bool run(simdjson::padded_string &json, uint64_t find_id, std::string_view &result) { bool run(simdjson::padded_string &json, uint64_t find_id, std::string_view &result) {
return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), find_id, result); return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), find_id, result);
} }
}; };
BENCHMARK_TEMPLATE(find_tweet, yyjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(find_tweet, yyjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace find_tweet } // namespace find_tweet
#endif // SIMDJSON_COMPETITION_YYJSON #endif // SIMDJSON_COMPETITION_YYJSON
+9 -7
View File
@@ -122,19 +122,21 @@ struct rapidjson_base {
}; };
using rapidjson_lossless = rapidjson_base<kParseValidateEncodingFlag|kParseFullPrecisionFlag>; using rapidjson = rapidjson_base<kParseValidateEncodingFlag|kParseFullPrecisionFlag>;
BENCHMARK_TEMPLATE(json2msgpack, rapidjson_lossless)->UseManualTime();
using rapidjson = rapidjson_base<kParseValidateEncodingFlag>;
BENCHMARK_TEMPLATE(json2msgpack, rapidjson)->UseManualTime(); BENCHMARK_TEMPLATE(json2msgpack, rapidjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_APPROX
using rapidjson_approx = rapidjson_base<kParseValidateEncodingFlag>;
BENCHMARK_TEMPLATE(json2msgpack, rapidjson_approx)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_APPROX
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
using rapidjson_insitu = rapidjson_base<kParseValidateEncodingFlag|kParseInsituFlag>; using rapidjson_insitu = rapidjson_base<kParseValidateEncodingFlag|kParseInsituFlag>;
BENCHMARK_TEMPLATE(json2msgpack, rapidjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(json2msgpack, rapidjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace json2msgpack } // namespace json2msgpack
#endif // SIMDJSON_COMPETITION_RAPIDJSON #endif // SIMDJSON_COMPETITION_RAPIDJSON
+2 -1
View File
@@ -106,6 +106,7 @@ struct yyjson : yyjson2msgpack {
BENCHMARK_TEMPLATE(json2msgpack, yyjson)->UseManualTime(); BENCHMARK_TEMPLATE(json2msgpack, yyjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct yyjson_insitu : yyjson2msgpack { struct yyjson_insitu : yyjson2msgpack {
bool run(simdjson::padded_string &json, char *buffer, bool run(simdjson::padded_string &json, char *buffer,
std::string_view &result) { std::string_view &result) {
@@ -116,7 +117,7 @@ struct yyjson_insitu : yyjson2msgpack {
} }
}; };
BENCHMARK_TEMPLATE(json2msgpack, yyjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(json2msgpack, yyjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace json2msgpack } // namespace json2msgpack
#endif // SIMDJSON_COMPETITION_YYJSON #endif // SIMDJSON_COMPETITION_YYJSON
+8 -7
View File
@@ -34,28 +34,29 @@ struct rapidjson_base {
return true; return true;
} }
}; };
#if SIMDJSON_COMPETITION_ONDEMAND_APPROX
struct rapidjson : rapidjson_base { struct rapidjson_approx : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag>(json.data()), result); return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(kostya, rapidjson)->UseManualTime(); BENCHMARK_TEMPLATE(kostya, rapidjson_approx)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_APPROX
struct rapidjson_lossless : rapidjson_base { struct rapidjson : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag | kParseFullPrecisionFlag>(json.data()), result); return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag | kParseFullPrecisionFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(kostya, rapidjson_lossless)->UseManualTime(); BENCHMARK_TEMPLATE(kostya, rapidjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct rapidjson_insitu : rapidjson_base { struct rapidjson_insitu : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result); return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(kostya, rapidjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(kostya, rapidjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace kostya } // namespace kostya
#endif // SIMDJSON_COMPETITION_RAPIDJSON #endif // SIMDJSON_COMPETITION_RAPIDJSON
+2 -2
View File
@@ -53,14 +53,14 @@ struct yyjson : yyjson_base {
} }
}; };
BENCHMARK_TEMPLATE(kostya, yyjson)->UseManualTime(); BENCHMARK_TEMPLATE(kostya, yyjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct yyjson_insitu : yyjson_base { struct yyjson_insitu : yyjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result); return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result);
} }
}; };
BENCHMARK_TEMPLATE(kostya, yyjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(kostya, yyjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace kostya } // namespace kostya
#endif // SIMDJSON_COMPETITION_YYJSON #endif // SIMDJSON_COMPETITION_YYJSON
+8 -6
View File
@@ -31,28 +31,30 @@ struct rapidjson_base {
return true; return true;
} }
}; };
#if SIMDJSON_COMPETITION_ONDEMAND_APPROX
struct rapidjson : rapidjson_base { struct rapidjson_approx : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag>(json.data()), result); return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(large_random, rapidjson)->UseManualTime(); BENCHMARK_TEMPLATE(large_random, rapidjson_approx)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_APPROX
struct rapidjson_lossless : rapidjson_base { struct rapidjson : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag | kParseFullPrecisionFlag>(json.data()), result); return rapidjson_base::run(doc.Parse<kParseValidateEncodingFlag | kParseFullPrecisionFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(large_random, rapidjson_lossless)->UseManualTime(); BENCHMARK_TEMPLATE(large_random, rapidjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct rapidjson_insitu : rapidjson_base { struct rapidjson_insitu : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result); return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(large_random, rapidjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(large_random, rapidjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace large_random } // namespace large_random
+2 -2
View File
@@ -51,14 +51,14 @@ struct yyjson : yyjson_base {
} }
}; };
BENCHMARK_TEMPLATE(large_random, yyjson)->UseManualTime(); BENCHMARK_TEMPLATE(large_random, yyjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct yyjson_insitu : yyjson_base { struct yyjson_insitu : yyjson_base {
bool run(simdjson::padded_string &json, std::vector<point> &result) { bool run(simdjson::padded_string &json, std::vector<point> &result) {
return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result); return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result);
} }
}; };
BENCHMARK_TEMPLATE(large_random, yyjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(large_random, yyjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace large_random } // namespace large_random
#endif // SIMDJSON_COMPETITION_YYJSON #endif // SIMDJSON_COMPETITION_YYJSON
+2 -2
View File
@@ -67,14 +67,14 @@ struct rapidjson : rapidjson_base {
} }
}; };
BENCHMARK_TEMPLATE(partial_tweets, rapidjson)->UseManualTime(); BENCHMARK_TEMPLATE(partial_tweets, rapidjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct rapidjson_insitu : rapidjson_base { struct rapidjson_insitu : rapidjson_base {
bool run(simdjson::padded_string &json, std::vector<tweet<std::string_view>> &result) { bool run(simdjson::padded_string &json, std::vector<tweet<std::string_view>> &result) {
return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result); return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), result);
} }
}; };
BENCHMARK_TEMPLATE(partial_tweets, rapidjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(partial_tweets, rapidjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace partial_tweets } // namespace partial_tweets
#endif // SIMDJSON_COMPETITION_RAPIDJSON #endif // SIMDJSON_COMPETITION_RAPIDJSON
+2 -2
View File
@@ -66,14 +66,14 @@ struct yyjson : yyjson_base {
} }
}; };
BENCHMARK_TEMPLATE(partial_tweets, yyjson)->UseManualTime(); BENCHMARK_TEMPLATE(partial_tweets, yyjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct yyjson_insitu : yyjson_base { struct yyjson_insitu : yyjson_base {
bool run(simdjson::padded_string &json, std::vector<tweet<std::string_view>> &result) { bool run(simdjson::padded_string &json, std::vector<tweet<std::string_view>> &result) {
return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result); return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), result);
} }
}; };
BENCHMARK_TEMPLATE(partial_tweets, yyjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(partial_tweets, yyjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace partial_tweets } // namespace partial_tweets
#endif // SIMDJSON_COMPETITION_YYJSON #endif // SIMDJSON_COMPETITION_YYJSON
+2 -2
View File
@@ -56,14 +56,14 @@ struct rapidjson : rapidjson_base {
} }
}; };
BENCHMARK_TEMPLATE(top_tweet, rapidjson)->UseManualTime(); BENCHMARK_TEMPLATE(top_tweet, rapidjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct rapidjson_insitu : rapidjson_base { struct rapidjson_insitu : rapidjson_base {
bool run(simdjson::padded_string &json, int64_t max_retweet_count, top_tweet_result<StringType> &result) { bool run(simdjson::padded_string &json, int64_t max_retweet_count, top_tweet_result<StringType> &result) {
return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), max_retweet_count, result); return rapidjson_base::run(doc.ParseInsitu<kParseValidateEncodingFlag|kParseInsituFlag>(json.data()), max_retweet_count, result);
} }
}; };
BENCHMARK_TEMPLATE(top_tweet, rapidjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(top_tweet, rapidjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace top_tweet } // namespace top_tweet
#endif // SIMDJSON_COMPETITION_RAPIDJSON #endif // SIMDJSON_COMPETITION_RAPIDJSON
+2 -2
View File
@@ -55,14 +55,14 @@ struct yyjson : yyjson_base {
} }
}; };
BENCHMARK_TEMPLATE(top_tweet, yyjson)->UseManualTime(); BENCHMARK_TEMPLATE(top_tweet, yyjson)->UseManualTime();
#if SIMDJSON_COMPETITION_ONDEMAND_INSITU
struct yyjson_insitu : yyjson_base { struct yyjson_insitu : yyjson_base {
bool run(simdjson::padded_string &json, int64_t max_retweet_count, top_tweet_result<StringType> &result) { bool run(simdjson::padded_string &json, int64_t max_retweet_count, top_tweet_result<StringType> &result) {
return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), max_retweet_count, result); return yyjson_base::run(yyjson_read_opts(json.data(), json.size(), YYJSON_READ_INSITU, 0, 0), max_retweet_count, result);
} }
}; };
BENCHMARK_TEMPLATE(top_tweet, yyjson_insitu)->UseManualTime(); BENCHMARK_TEMPLATE(top_tweet, yyjson_insitu)->UseManualTime();
#endif // SIMDJSON_COMPETITION_ONDEMAND_INSITU
} // namespace top_tweet } // namespace top_tweet
#endif // SIMDJSON_COMPETITION_YYJSON #endif // SIMDJSON_COMPETITION_YYJSON
+2 -2
View File
@@ -91,7 +91,7 @@ int main() {}
target_include_directories(jsoncpp SYSTEM PUBLIC "${jsoncpp_SOURCE_DIR}") target_include_directories(jsoncpp SYSTEM PUBLIC "${jsoncpp_SOURCE_DIR}")
target_compile_definitions(jsoncpp INTERFACE SIMDJSON_COMPETITION_JSONCPP) target_compile_definitions(jsoncpp INTERFACE SIMDJSON_COMPETITION_JSONCPP)
import_dependency(rapidjson Tencent/rapidjson b32cd94) import_dependency(rapidjson Tencent/rapidjson f54b0e4)
add_library(rapidjson INTERFACE) add_library(rapidjson INTERFACE)
target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING) target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING)
target_include_directories(rapidjson SYSTEM INTERFACE target_include_directories(rapidjson SYSTEM INTERFACE
@@ -114,7 +114,7 @@ int main() {}
"${ujson4c_SOURCE_DIR}/3rdparty") "${ujson4c_SOURCE_DIR}/3rdparty")
target_compile_definitions(ujson4c INTERFACE SIMDJSON_COMPETITION_UJSON4C) target_compile_definitions(ujson4c INTERFACE SIMDJSON_COMPETITION_UJSON4C)
import_dependency(yyjson ibireme/yyjson aa33ec5) import_dependency(yyjson ibireme/yyjson c385651)
add_library(yyjson STATIC "${yyjson_SOURCE_DIR}/src/yyjson.c") add_library(yyjson STATIC "${yyjson_SOURCE_DIR}/src/yyjson.c")
target_include_directories(yyjson SYSTEM PUBLIC "${yyjson_SOURCE_DIR}/src") target_include_directories(yyjson SYSTEM PUBLIC "${yyjson_SOURCE_DIR}/src")
target_compile_definitions(yyjson INTERFACE SIMDJSON_COMPETITION_YYJSON) target_compile_definitions(yyjson INTERFACE SIMDJSON_COMPETITION_YYJSON)
+4 -2
View File
@@ -433,7 +433,8 @@ support for users who avoid exceptions. See [the simdjson error handling documen
* **Counting elements in arrays:** Sometimes it is useful to scan an array to determine its length prior to parsing it. * **Counting elements in arrays:** Sometimes it is useful to scan an array to determine its length prior to parsing it.
For this purpose, `array` instances have a `count_elements` method. Users should be For this purpose, `array` instances have a `count_elements` method. Users should be
aware that the `count_elements` method can be costly since it requires scanning the aware that the `count_elements` method can be costly since it requires scanning the
whole array. You may use it as follows if your document is itself an array: whole array. You should only call `count_elements` as a last resort as it may
require scanning the document twice or more. You may use it as follows if your document is itself an array:
```C++ ```C++
auto cars_json = R"( [ 40.1, 39.9, 37.7, 40.4 ] )"_padded; auto cars_json = R"( [ 40.1, 39.9, 37.7, 40.4 ] )"_padded;
@@ -460,7 +461,8 @@ support for users who avoid exceptions. See [the simdjson error handling documen
parsing it. parsing it.
For this purpose, `object` instances have a `count_fields` method. Again, users should be For this purpose, `object` instances have a `count_fields` method. Again, users should be
aware that the `count_fields` method can be costly since it requires scanning the aware that the `count_fields` method can be costly since it requires scanning the
whole objects. You may use it as follows if your document is itself an object: whole objects. You should only call `count_fields` as a last resort as it may
require scanning the document twice or more. You may use it as follows if your document is itself an object:
```C++ ```C++
ondemand::parser parser; ondemand::parser parser;
@@ -139,20 +139,14 @@ simdjson_inline simdjson_result<size_t> document::count_elements() & noexcept {
auto a = get_array(); auto a = get_array();
simdjson_result<size_t> answer = a.count_elements(); simdjson_result<size_t> answer = a.count_elements();
/* If there was an array, we are now left pointing at its first element. */ /* If there was an array, we are now left pointing at its first element. */
if(answer.error() == SUCCESS) { if(answer.error() == SUCCESS) { rewind(); }
iter._depth = 1 ; /* undoing the increment so we go back at the doc depth.*/
iter.assert_at_document_depth();
}
return answer; return answer;
} }
simdjson_inline simdjson_result<size_t> document::count_fields() & noexcept { simdjson_inline simdjson_result<size_t> document::count_fields() & noexcept {
auto a = get_object(); auto a = get_object();
simdjson_result<size_t> answer = a.count_fields(); simdjson_result<size_t> answer = a.count_fields();
/* If there was an array, we are now left pointing at its first element. */ /* If there was an object, we are now left pointing at its first element. */
if(answer.error() == SUCCESS) { if(answer.error() == SUCCESS) { rewind(); }
iter._depth = 1 ; /* undoing the increment so we go back at the doc depth.*/
iter.assert_at_document_depth();
}
return answer; return answer;
} }
simdjson_inline simdjson_result<value> document::at(size_t index) & noexcept { simdjson_inline simdjson_result<value> document::at(size_t index) & noexcept {
@@ -166,6 +166,9 @@ public:
* *
* To check that an object is empty, it is more performant to use * To check that an object is empty, it is more performant to use
* the is_empty() method. * the is_empty() method.
*
* Performance hint: You should only call count_fields() as a last
* resort as it may require scanning the document twice or more.
*/ */
simdjson_inline simdjson_result<size_t> count_fields() & noexcept; simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
/** /**
@@ -246,6 +246,9 @@ public:
* beginning as if it had never been accessed. If the JSON is malformed (e.g., * beginning as if it had never been accessed. If the JSON is malformed (e.g.,
* there is a missing comma), then an error is returned and it is no longer * there is a missing comma), then an error is returned and it is no longer
* safe to continue. * safe to continue.
*
* Performance hint: You should only call count_elements() as a last
* resort as it may require scanning the document twice or more.
*/ */
simdjson_inline simdjson_result<size_t> count_elements() & noexcept; simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
/** /**
@@ -261,6 +264,9 @@ public:
* *
* To check that an object is empty, it is more performant to use * To check that an object is empty, it is more performant to use
* the is_empty() method on the object instance. * the is_empty() method on the object instance.
*
* Performance hint: You should only call count_fields() as a last
* resort as it may require scanning the document twice or more.
*/ */
simdjson_inline simdjson_result<size_t> count_fields() & noexcept; simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
/** /**
+2 -2
View File
@@ -4,7 +4,7 @@
#define SIMDJSON_SIMDJSON_VERSION_H #define SIMDJSON_SIMDJSON_VERSION_H
/** The version of simdjson being used (major.minor.revision) */ /** The version of simdjson being used (major.minor.revision) */
#define SIMDJSON_VERSION 2.2.1 #define SIMDJSON_VERSION 2.2.2
namespace simdjson { namespace simdjson {
enum { enum {
@@ -19,7 +19,7 @@ enum {
/** /**
* The revision (major.minor.REVISION) of simdjson being used. * The revision (major.minor.REVISION) of simdjson being used.
*/ */
SIMDJSON_VERSION_REVISION = 1 SIMDJSON_VERSION_REVISION = 2
}; };
} // namespace simdjson } // namespace simdjson
+1 -13
View File
@@ -1,4 +1,4 @@
/* auto-generated on 2022-07-19 16:40:02 -0400. Do not edit! */ /* auto-generated on 2022-07-28 21:45:54 -0400. Do not edit! */
/* begin file src/simdjson.cpp */ /* begin file src/simdjson.cpp */
#include "simdjson.h" #include "simdjson.h"
@@ -4183,8 +4183,6 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
// multilingual plane check // multilingual plane check
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2); uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
*src_ptr += 6; *src_ptr += 6;
if (code_point >= 0xd800 && code_point < 0xdc00) {
}
// If we found a high surrogate, we must // If we found a high surrogate, we must
// check for low surrogate for characters // check for low surrogate for characters
@@ -5659,8 +5657,6 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
// multilingual plane check // multilingual plane check
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2); uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
*src_ptr += 6; *src_ptr += 6;
if (code_point >= 0xd800 && code_point < 0xdc00) {
}
// If we found a high surrogate, we must // If we found a high surrogate, we must
// check for low surrogate for characters // check for low surrogate for characters
@@ -8013,8 +8009,6 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
// multilingual plane check // multilingual plane check
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2); uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
*src_ptr += 6; *src_ptr += 6;
if (code_point >= 0xd800 && code_point < 0xdc00) {
}
// If we found a high surrogate, we must // If we found a high surrogate, we must
// check for low surrogate for characters // check for low surrogate for characters
@@ -10349,8 +10343,6 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
// multilingual plane check // multilingual plane check
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2); uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
*src_ptr += 6; *src_ptr += 6;
if (code_point >= 0xd800 && code_point < 0xdc00) {
}
// If we found a high surrogate, we must // If we found a high surrogate, we must
// check for low surrogate for characters // check for low surrogate for characters
@@ -12648,8 +12640,6 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
// multilingual plane check // multilingual plane check
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2); uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
*src_ptr += 6; *src_ptr += 6;
if (code_point >= 0xd800 && code_point < 0xdc00) {
}
// If we found a high surrogate, we must // If we found a high surrogate, we must
// check for low surrogate for characters // check for low surrogate for characters
@@ -14982,8 +14972,6 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
// multilingual plane check // multilingual plane check
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2); uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
*src_ptr += 6; *src_ptr += 6;
if (code_point >= 0xd800 && code_point < 0xdc00) {
}
// If we found a high surrogate, we must // If we found a high surrogate, we must
// check for low surrogate for characters // check for low surrogate for characters
+15 -12
View File
@@ -1,4 +1,4 @@
/* auto-generated on 2022-07-19 16:40:02 -0400. Do not edit! */ /* auto-generated on 2022-07-28 21:45:54 -0400. Do not edit! */
/* begin file include/simdjson.h */ /* begin file include/simdjson.h */
#ifndef SIMDJSON_H #ifndef SIMDJSON_H
#define SIMDJSON_H #define SIMDJSON_H
@@ -43,7 +43,7 @@
#define SIMDJSON_SIMDJSON_VERSION_H #define SIMDJSON_SIMDJSON_VERSION_H
/** The version of simdjson being used (major.minor.revision) */ /** The version of simdjson being used (major.minor.revision) */
#define SIMDJSON_VERSION 2.2.1 #define SIMDJSON_VERSION 2.2.2
namespace simdjson { namespace simdjson {
enum { enum {
@@ -58,7 +58,7 @@ enum {
/** /**
* The revision (major.minor.REVISION) of simdjson being used. * The revision (major.minor.REVISION) of simdjson being used.
*/ */
SIMDJSON_VERSION_REVISION = 1 SIMDJSON_VERSION_REVISION = 2
}; };
} // namespace simdjson } // namespace simdjson
@@ -25318,6 +25318,9 @@ public:
* beginning as if it had never been accessed. If the JSON is malformed (e.g., * beginning as if it had never been accessed. If the JSON is malformed (e.g.,
* there is a missing comma), then an error is returned and it is no longer * there is a missing comma), then an error is returned and it is no longer
* safe to continue. * safe to continue.
*
* Performance hint: You should only call count_elements() as a last
* resort as it may require scanning the document twice or more.
*/ */
simdjson_inline simdjson_result<size_t> count_elements() & noexcept; simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
/** /**
@@ -25333,6 +25336,9 @@ public:
* *
* To check that an object is empty, it is more performant to use * To check that an object is empty, it is more performant to use
* the is_empty() method on the object instance. * the is_empty() method on the object instance.
*
* Performance hint: You should only call count_fields() as a last
* resort as it may require scanning the document twice or more.
*/ */
simdjson_inline simdjson_result<size_t> count_fields() & noexcept; simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
/** /**
@@ -25989,6 +25995,9 @@ public:
* *
* To check that an object is empty, it is more performant to use * To check that an object is empty, it is more performant to use
* the is_empty() method. * the is_empty() method.
*
* Performance hint: You should only call count_fields() as a last
* resort as it may require scanning the document twice or more.
*/ */
simdjson_inline simdjson_result<size_t> count_fields() & noexcept; simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
/** /**
@@ -29308,20 +29317,14 @@ simdjson_inline simdjson_result<size_t> document::count_elements() & noexcept {
auto a = get_array(); auto a = get_array();
simdjson_result<size_t> answer = a.count_elements(); simdjson_result<size_t> answer = a.count_elements();
/* If there was an array, we are now left pointing at its first element. */ /* If there was an array, we are now left pointing at its first element. */
if(answer.error() == SUCCESS) { if(answer.error() == SUCCESS) { rewind(); }
iter._depth = 1 ; /* undoing the increment so we go back at the doc depth.*/
iter.assert_at_document_depth();
}
return answer; return answer;
} }
simdjson_inline simdjson_result<size_t> document::count_fields() & noexcept { simdjson_inline simdjson_result<size_t> document::count_fields() & noexcept {
auto a = get_object(); auto a = get_object();
simdjson_result<size_t> answer = a.count_fields(); simdjson_result<size_t> answer = a.count_fields();
/* If there was an array, we are now left pointing at its first element. */ /* If there was an object, we are now left pointing at its first element. */
if(answer.error() == SUCCESS) { if(answer.error() == SUCCESS) { rewind(); }
iter._depth = 1 ; /* undoing the increment so we go back at the doc depth.*/
iter.assert_at_document_depth();
}
return answer; return answer;
} }
simdjson_inline simdjson_result<value> document::at(size_t index) & noexcept { simdjson_inline simdjson_result<value> document::at(size_t index) & noexcept {
-2
View File
@@ -47,8 +47,6 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
// multilingual plane check // multilingual plane check
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2); uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
*src_ptr += 6; *src_ptr += 6;
if (code_point >= 0xd800 && code_point < 0xdc00) {
}
// If we found a high surrogate, we must // If we found a high surrogate, we must
// check for low surrogate for characters // check for low surrogate for characters
+21
View File
@@ -128,6 +128,26 @@ namespace array_tests {
TEST_SUCCEED(); TEST_SUCCEED();
} }
bool issue1876() {
TEST_START();
auto json = R"( [] )"_padded;
ondemand::parser parser;
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
size_t count;
ASSERT_SUCCESS(doc.count_elements().get(count));
ondemand::array arr;
ASSERT_SUCCESS(doc.get_array().get(arr));
ASSERT_EQUAL(count, 0);
for (auto element : arr) {
double value;
ASSERT_SUCCESS(element.get_double().get(value));
std::cout << value << std::endl;
}
TEST_SUCCEED();
}
bool iterate_complex_array_count() { bool iterate_complex_array_count() {
TEST_START(); TEST_START();
ondemand::parser parser; ondemand::parser parser;
@@ -810,6 +830,7 @@ namespace array_tests {
bool run() { bool run() {
return return
issue1876() &&
issue1742() && issue1742() &&
empty_rewind_convoluted() && empty_rewind_convoluted() &&
empty_rewind() && empty_rewind() &&
+45
View File
@@ -896,6 +896,49 @@ namespace object_tests {
TEST_SUCCEED(); TEST_SUCCEED();
} }
bool issue1876a() {
TEST_START();
auto json = R"( {} )"_padded;
ondemand::parser parser;
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
ondemand::object obj;
ASSERT_SUCCESS(doc.get_object().get(obj));
size_t count;
ASSERT_SUCCESS(obj.count_fields().get(count));
ASSERT_EQUAL(count, 0);
for (auto field : obj) {
std::string_view key;
ASSERT_SUCCESS(field.unescaped_key().get(key));
double value;
ASSERT_SUCCESS(field.value().get_double().get(value));
std::cout << key << " " << value << std::endl;
}
TEST_SUCCEED();
}
bool issue1876() {
TEST_START();
auto json = R"( {} )"_padded;
ondemand::parser parser;
ondemand::document doc;
ASSERT_SUCCESS(parser.iterate(json).get(doc));
size_t count;
ASSERT_SUCCESS(doc.count_fields().get(count));
ondemand::object obj;
ASSERT_SUCCESS(doc.get_object().get(obj));
ASSERT_EQUAL(count, 0);
for (auto field : obj) {
std::string_view key;
ASSERT_SUCCESS(field.unescaped_key().get(key));
double value;
ASSERT_SUCCESS(field.value().get_double().get(value));
std::cout << key << " " << value << std::endl;
}
TEST_SUCCEED();
}
bool issue1742() { bool issue1742() {
TEST_START(); TEST_START();
auto json = R"( { auto json = R"( {
@@ -1178,6 +1221,8 @@ namespace object_tests {
bool run() { bool run() {
return return
issue1876a() &&
issue1876() &&
test_strager() && test_strager() &&
issue1745() && issue1745() &&
issue1742() && issue1742() &&