useStlAlgorithm: ranges algorithms + justifica returnDanglingLifetime
This commit is contained in:
1 parent
d7db02bafd
commit
822bed0748
5 files changed
+15
-25
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
|
||||
#include "utils/log.hpp"
|
||||
|
||||
@@ -19,12 +20,7 @@ namespace Resource {
|
||||
auto Pack::calculateChecksum(const std::vector<std::uint8_t>& data) -> std::uint32_t {
|
||||
// djb2: seed 0x12345678. Compatible amb aee/projecte_2026 per si mai
|
||||
// reutilitzem eines de diagnòstic entre projectes.
|
||||
std::uint32_t checksum = 0x12345678;
|
||||
for (unsigned char b : data) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
checksum = ((checksum << 5) + checksum) + b;
|
||||
}
|
||||
return checksum;
|
||||
return std::accumulate(data.begin(), data.end(), std::uint32_t{0x12345678}, [](std::uint32_t acc, unsigned char b) { return ((acc << 5) + acc) + b; });
|
||||
}
|
||||
|
||||
void Pack::xorInPlace(std::vector<std::uint8_t>& data, const std::string& key) {
|
||||
@@ -151,7 +147,7 @@ namespace Resource {
|
||||
return false;
|
||||
}
|
||||
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
// cppcheck-suppress useStlAlgorithm -- bucle amb early-return en error (addFile fallit) + filtre amb continue: no es pot expressar net amb std::ranges::all_of perquè la lògica combina filtratge i acumulació amb sortida prematura.
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator(directory)) {
|
||||
if (!entry.is_regular_file()) { continue; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user