From c038f776b1a2c2d38f01c8ebeb7e259bb1879fc7 Mon Sep 17 00:00:00 2001 From: "G.E" Date: Fri, 17 May 2024 11:02:00 +0300 Subject: [PATCH] last batch --- examples/patbench.cc | 9 ++++++--- examples/pcapscan.cc | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/patbench.cc b/examples/patbench.cc index 1f965f13..132e416f 100644 --- a/examples/patbench.cc +++ b/examples/patbench.cc @@ -358,9 +358,11 @@ public: // Return the number of bytes scanned size_t bytes() const { size_t sum = 0; - for (const auto &packet : packets) { - sum += packet.size(); - } + auto packs = [](size_t z, const string &packet) { return z + packet.size(); }; + sum += std::accumulate(packets.begin(), packets.end(), 0, packs); + // for (const auto &packet : packets) { + // sum += packet.size(); + // } return sum; } @@ -461,6 +463,7 @@ public: vector cstrPatterns; cstrPatterns.reserve(patterns.size()); for (const auto &pattern : patterns) { + // cppcheck-suppress useStlAlgorithm cstrPatterns.push_back(pattern.c_str()); } diff --git a/examples/pcapscan.cc b/examples/pcapscan.cc index bd5493a4..071de740 100644 --- a/examples/pcapscan.cc +++ b/examples/pcapscan.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -250,9 +251,8 @@ public: // Return the number of bytes scanned size_t bytes() const { size_t sum = 0; - for (const auto &packet : packets) { - sum += packet.size(); - } + auto packs = [](size_t z, const string &packet) { return z + packet.size(); }; + sum += std::accumulate(packets.begin(), packets.end(), 0, packs); return sum; } @@ -433,6 +433,7 @@ static void databasesFromFile(const char *filename, // storage.) vector cstrPatterns; for (const auto &pattern : patterns) { + // cppcheck-suppress useStlAlgorithm cstrPatterns.push_back(pattern.c_str()); }