Add SIMDJSON_FORCE_IMPLEMENTATION

This commit is contained in:
John Keiser
2020-04-18 16:37:11 -07:00
parent 3be81e3206
commit 22b9a53bef
7 changed files with 83 additions and 9 deletions
+9
View File
@@ -122,6 +122,15 @@ const implementation *available_implementation_list::detect_best_supported() con
}
const implementation *detect_best_supported_implementation_on_first_use::set_best() const noexcept {
char *force_implementation_name = getenv("SIMDJSON_FORCE_IMPLEMENTATION");
if (force_implementation_name) {
auto force_implementation = available_implementations[force_implementation_name];
if (!force_implementation) {
fprintf(stderr, "SIMDJSON_FORCE_IMPLEMENTATION environment variable set to '%s', which is not a supported implementation name!\n", force_implementation_name);
abort();
}
return active_implementation = force_implementation;
}
return active_implementation = available_implementations.detect_best_supported();
}