mirror of
https://github.com/nlohmann/json.git
synced 2026-10-03 13:10:33 +00:00
Merge branch 'json-view/16-view-simd' into json-view/18-view-object-index
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -40,6 +40,8 @@ class string_ref
|
|||||||
using const_iterator = const char*;
|
using const_iterator = const char*;
|
||||||
|
|
||||||
string_ref() noexcept = default;
|
string_ref() noexcept = default;
|
||||||
|
// s must be null-terminated, as for std::string_view(const char*)
|
||||||
|
// flawfinder: ignore
|
||||||
string_ref(const char* s) : m_data(s), m_size(std::strlen(s)) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
string_ref(const char* s) : m_data(s), m_size(std::strlen(s)) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||||
string_ref(const char* s, std::size_t n) noexcept : m_data(s), m_size(n) {}
|
string_ref(const char* s, std::size_t n) noexcept : m_data(s), m_size(n) {}
|
||||||
template<typename Traits, typename Alloc>
|
template<typename Traits, typename Alloc>
|
||||||
|
|||||||
@@ -872,6 +872,7 @@ class basic_json_document
|
|||||||
|
|
||||||
/// parse into this document, reusing its memory
|
/// parse into this document, reusing its memory
|
||||||
template<typename InputType>
|
template<typename InputType>
|
||||||
|
// flawfinder: ignore (a member function, not POSIX read())
|
||||||
void read(InputType&& input,
|
void read(InputType&& input,
|
||||||
const bool allow_exceptions = true,
|
const bool allow_exceptions = true,
|
||||||
const bool ignore_comments = false,
|
const bool ignore_comments = false,
|
||||||
@@ -1044,6 +1045,8 @@ class basic_json_document
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char* cs = reinterpret_cast<const char*>(s); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
|
const char* cs = reinterpret_cast<const char*>(s); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||||
|
// C strings are null-terminated, as for json::parse(const char*)
|
||||||
|
// flawfinder: ignore
|
||||||
build(cs, std::strlen(cs), ae, c, tc, false, true);
|
build(cs, std::strlen(cs), ae, c, tc, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3930,6 +3930,8 @@ class string_ref
|
|||||||
using const_iterator = const char*;
|
using const_iterator = const char*;
|
||||||
|
|
||||||
string_ref() noexcept = default;
|
string_ref() noexcept = default;
|
||||||
|
// s must be null-terminated, as for std::string_view(const char*)
|
||||||
|
// flawfinder: ignore
|
||||||
string_ref(const char* s) : m_data(s), m_size(std::strlen(s)) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
string_ref(const char* s) : m_data(s), m_size(std::strlen(s)) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||||
string_ref(const char* s, std::size_t n) noexcept : m_data(s), m_size(n) {}
|
string_ref(const char* s, std::size_t n) noexcept : m_data(s), m_size(n) {}
|
||||||
template<typename Traits, typename Alloc>
|
template<typename Traits, typename Alloc>
|
||||||
@@ -4925,6 +4927,7 @@ class basic_json_document
|
|||||||
|
|
||||||
/// parse into this document, reusing its memory
|
/// parse into this document, reusing its memory
|
||||||
template<typename InputType>
|
template<typename InputType>
|
||||||
|
// flawfinder: ignore (a member function, not POSIX read())
|
||||||
void read(InputType&& input,
|
void read(InputType&& input,
|
||||||
const bool allow_exceptions = true,
|
const bool allow_exceptions = true,
|
||||||
const bool ignore_comments = false,
|
const bool ignore_comments = false,
|
||||||
@@ -5097,6 +5100,8 @@ class basic_json_document
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char* cs = reinterpret_cast<const char*>(s); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
|
const char* cs = reinterpret_cast<const char*>(s); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||||
|
// C strings are null-terminated, as for json::parse(const char*)
|
||||||
|
// flawfinder: ignore
|
||||||
build(cs, std::strlen(cs), ae, c, tc, false, true);
|
build(cs, std::strlen(cs), ae, c, tc, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ import platform
|
|||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
# runs only the compilers and benchmark binaries this script builds
|
||||||
|
import subprocess # nosec B404
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
@@ -71,12 +72,14 @@ DEFAULT_CORPUS = [
|
|||||||
|
|
||||||
def run(cmd, **kwargs):
|
def run(cmd, **kwargs):
|
||||||
print('+ ' + ' '.join(shlex.quote(c) for c in cmd), flush=True)
|
print('+ ' + ' '.join(shlex.quote(c) for c in cmd), flush=True)
|
||||||
return subprocess.run(cmd, check=True, **kwargs)
|
# cmd is an argument list built by this script, never a shell string
|
||||||
|
return subprocess.run(cmd, check=True, **kwargs) # nosec B603
|
||||||
|
|
||||||
|
|
||||||
def output(cmd):
|
def output(cmd):
|
||||||
try:
|
try:
|
||||||
return subprocess.run(cmd, check=True, capture_output=True, text=True).stdout.strip()
|
# cmd is an argument list built by this script, never a shell string
|
||||||
|
return subprocess.run(cmd, check=True, capture_output=True, text=True).stdout.strip() # nosec B603
|
||||||
except (OSError, subprocess.CalledProcessError):
|
except (OSError, subprocess.CalledProcessError):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@@ -150,7 +153,8 @@ def download_library(name, work):
|
|||||||
os.makedirs(os.path.dirname(archive), exist_ok=True)
|
os.makedirs(os.path.dirname(archive), exist_ok=True)
|
||||||
if not os.path.isfile(archive):
|
if not os.path.isfile(archive):
|
||||||
print(f'downloading {pin["url"]}', flush=True)
|
print(f'downloading {pin["url"]}', flush=True)
|
||||||
urllib.request.urlretrieve(pin['url'], archive)
|
# the URLs are the https constants in PINNED, and the SHA-256 is checked below
|
||||||
|
urllib.request.urlretrieve(pin['url'], archive) # nosec B310
|
||||||
with open(archive, 'rb') as f:
|
with open(archive, 'rb') as f:
|
||||||
digest = hashlib.sha256(f.read()).hexdigest()
|
digest = hashlib.sha256(f.read()).hexdigest()
|
||||||
if digest != pin['sha256']:
|
if digest != pin['sha256']:
|
||||||
@@ -160,7 +164,7 @@ def download_library(name, work):
|
|||||||
with tarfile.open(archive) as t:
|
with tarfile.open(archive) as t:
|
||||||
# (the 'data' filter rejects links and paths outside the target where Python has it)
|
# (the 'data' filter rejects links and paths outside the target where Python has it)
|
||||||
kwargs = {'filter': 'data'} if hasattr(tarfile, 'data_filter') else {}
|
kwargs = {'filter': 'data'} if hasattr(tarfile, 'data_filter') else {}
|
||||||
t.extractall(os.path.join(work, 'download'), **kwargs) # noqa: S202 (checked archive)
|
t.extractall(os.path.join(work, 'download'), **kwargs) # noqa: S202 (checked archive) # nosec B202
|
||||||
if name == 'yyjson':
|
if name == 'yyjson':
|
||||||
return Library(name, [os.path.join(src, 'src')], [os.path.join(src, 'src', 'yyjson.c')], [], pin['version'])
|
return Library(name, [os.path.join(src, 'src')], [os.path.join(src, 'src', 'yyjson.c')], [], pin['version'])
|
||||||
if name == 'simdjson':
|
if name == 'simdjson':
|
||||||
|
|||||||
Reference in New Issue
Block a user