mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-16 09:21:52 +03:00
Merge pull request #277 from isildur-g/wip-cppcheck271
phase 1 of addressing cppcheck useStlAlgorithm warnings for fill and copy operations
This commit is contained in:
@@ -227,11 +227,13 @@ vector<u32> removeClique(CliqueGraph &cg) {
|
||||
while (!graph_empty(cg)) {
|
||||
const vector<u32> &c = cliquesVec.back();
|
||||
vector<CliqueVertex> dead;
|
||||
for (const auto &v : vertices_range(cg)) {
|
||||
if (find(c.begin(), c.end(), cg[v].stateId) != c.end()) {
|
||||
dead.emplace_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
auto deads = [&c=c, &cg=cg](const CliqueVertex &v) {
|
||||
return (find(c.begin(), c.end(), cg[v].stateId) != c.end());
|
||||
};
|
||||
const auto &vr = vertices_range(cg);
|
||||
std::copy_if(begin(vr), end(vr), std::back_inserter(dead), deads);
|
||||
|
||||
for (const auto &v : dead) {
|
||||
clear_vertex(v, cg);
|
||||
remove_vertex(v, cg);
|
||||
|
||||
@@ -329,11 +329,11 @@ void buildReachMapping(const build_info &args, vector<NFAStateSet> &reach,
|
||||
// Build a list of vertices with a state index assigned.
|
||||
vector<NFAVertex> verts;
|
||||
verts.reserve(args.num_states);
|
||||
for (auto v : vertices_range(h)) {
|
||||
if (state_ids.at(v) != NO_STATE) {
|
||||
verts.emplace_back(v);
|
||||
}
|
||||
}
|
||||
auto sidat = [&state_ids=state_ids](const NFAVertex &v) {
|
||||
return (state_ids.at(v) != NO_STATE);
|
||||
};
|
||||
const auto &vr = vertices_range(h);
|
||||
std::copy_if(begin(vr), end(vr), std::back_inserter(verts), sidat);
|
||||
|
||||
// Build a mapping from set-of-states -> reachability.
|
||||
map<NFAStateSet, CharReach> mapping;
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <numeric>
|
||||
|
||||
|
||||
#include "tamaramacompile.h"
|
||||
|
||||
@@ -127,9 +129,10 @@ buildTamarama(const TamaInfo &tamaInfo, const u32 queue,
|
||||
sizeof(u32) * subSize + 64; // offsets to subengines in bytecode and
|
||||
// padding for subengines
|
||||
|
||||
for (const auto &sub : tamaInfo.subengines) {
|
||||
total_size += ROUNDUP_CL(sub->length);
|
||||
}
|
||||
auto subl = [](size_t z, NFA *sub) {
|
||||
return z + (size_t)(ROUNDUP_CL(sub->length));
|
||||
};
|
||||
total_size += std::accumulate(tamaInfo.subengines.begin(), tamaInfo.subengines.end(), 0, subl);
|
||||
|
||||
// use subSize as a sentinel value for no active subengines,
|
||||
// so add one to subSize here
|
||||
|
||||
Reference in New Issue
Block a user