Modernize `std::search` with ranges
The new return value is `std::ranges::subrange`.
This commit is contained in:
parent
0352f24a8e
commit
4fde0f2868
|
@ -240,11 +240,9 @@ bool NANDImporter::ExtractCertificates()
|
||||||
|
|
||||||
for (const PEMCertificate& certificate : certificates)
|
for (const PEMCertificate& certificate : certificates)
|
||||||
{
|
{
|
||||||
const auto search_result =
|
const auto search_result = std::ranges::search(content_bytes, certificate.search_bytes);
|
||||||
std::search(content_bytes.begin(), content_bytes.end(), certificate.search_bytes.begin(),
|
|
||||||
certificate.search_bytes.end());
|
|
||||||
|
|
||||||
if (search_result == content_bytes.end())
|
if (search_result.empty())
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(DISCIO, "ExtractCertificates: Could not find offset for certficate '{}'",
|
ERROR_LOG_FMT(DISCIO, "ExtractCertificates: Could not find offset for certficate '{}'",
|
||||||
certificate.filename);
|
certificate.filename);
|
||||||
|
@ -252,7 +250,8 @@ bool NANDImporter::ExtractCertificates()
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string pem_file_path = m_nand_root + std::string(certificate.filename);
|
const std::string pem_file_path = m_nand_root + std::string(certificate.filename);
|
||||||
const ptrdiff_t certificate_offset = std::distance(content_bytes.begin(), search_result);
|
const ptrdiff_t certificate_offset =
|
||||||
|
std::distance(content_bytes.begin(), search_result.begin());
|
||||||
constexpr int min_offset = 2;
|
constexpr int min_offset = 2;
|
||||||
if (certificate_offset < min_offset)
|
if (certificate_offset < min_offset)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue