addressing 47 [constParameterReference],48 [constVariableReference],58

[constVariable]
This commit is contained in:
G.E
2024-05-01 10:54:15 +03:00
parent 5ebc19674c
commit 98243a6a08
40 changed files with 146 additions and 146 deletions

View File

@@ -292,7 +292,7 @@ bool addComponent(NG &ng, NGHolder &g, const ExpressionInfo &expr,
// Returns true if all components have been added.
static
bool processComponents(NG &ng, ExpressionInfo &expr,
bool processComponents(NG &ng, const ExpressionInfo &expr,
deque<unique_ptr<NGHolder>> &g_comp,
const som_type som) {
const u32 num_components = g_comp.size();

View File

@@ -257,7 +257,7 @@ void reformAnchoredRepeatsComponent(NGHolder &g,
static
void reformUnanchoredRepeatsComponent(NGHolder &g,
set<NFAVertex> &compAnchoredStarts,
const set<NFAVertex> &compAnchoredStarts,
set<NFAVertex> &compUnanchoredStarts,
set<NFAVertex> &dead,
depth *startBegin, depth *startEnd) {
@@ -555,7 +555,7 @@ void collapseVariableRepeats(NGHolder &g, depth *startBegin, depth *startEnd) {
}
static
void addDotsBetween(NGHolder &g, NFAVertex lhs, vector<NFAVertex> &rhs,
void addDotsBetween(NGHolder &g, NFAVertex lhs, const vector<NFAVertex> &rhs,
depth min_repeat, depth max_repeat) {
const bool unbounded = max_repeat.is_infinite();
if (unbounded) {

View File

@@ -159,7 +159,7 @@ public:
return id;
}
void append(WorkQueue &other) {
void append(const WorkQueue &other) {
for (const auto &e : other) {
push(e);
}
@@ -193,7 +193,7 @@ private:
}
static
bool outIsIrreducible(NFAVertex &v, const NGHolder &g) {
bool outIsIrreducible(const NFAVertex &v, const NGHolder &g) {
unsigned nonSpecialVertices = 0;
for (auto w : adjacent_vertices_range(v, g)) {
if (!is_special(w, g) && w != v) {
@@ -204,7 +204,7 @@ bool outIsIrreducible(NFAVertex &v, const NGHolder &g) {
}
static
bool inIsIrreducible(NFAVertex &v, const NGHolder &g) {
bool inIsIrreducible(const NFAVertex &v, const NGHolder &g) {
unsigned nonSpecialVertices = 0;
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!is_special(u, g) && u != v) {

View File

@@ -430,7 +430,7 @@ NFAVertex findSingleCyclic(const NGHolder &g) {
}
static
bool hasOffsetAdjust(const ReportManager &rm, NGHolder &g,
bool hasOffsetAdjust(const ReportManager &rm, const NGHolder &g,
int *adjust) {
const auto &reports = all_reports(g);
if (reports.empty()) {

View File

@@ -582,7 +582,7 @@ private:
// set up all reports
bool clone = false;
for (auto &pair : reports_to_vertices) {
for (const auto &pair : reports_to_vertices) {
const auto &reports = pair.first;
const auto &vertices = pair.second;

View File

@@ -98,7 +98,7 @@ void addToString(string &s, const NGHolder &g, NFAVertex v) {
}
static
bool splitOffLiteral(NG &ng, NGHolder &g, NFAVertex v, const bool anchored,
bool splitOffLiteral(NG &ng, const NGHolder &g, NFAVertex v, const bool anchored,
set<NFAVertex> &dead) {
DEBUG_PRINTF("examine vertex %zu\n", g[v].index);
bool nocase = false, casefixed = false;

View File

@@ -241,7 +241,7 @@ u32 allowedSquashDistance(const CharReach &cr, u32 min_width, const NGHolder &g,
/** Gives a stronger puff trigger when the trigger is connected to a wide
* cyclic state (aside from sds) */
static
void improveHead(NGHolder &g, NFAVertex *a, vector<NFAVertex> *nodes) {
void improveHead(const NGHolder &g, NFAVertex *a, vector<NFAVertex> *nodes) {
DEBUG_PRINTF("attempting to improve puff trigger\n");
assert(!nodes->empty());
const CharReach &puff_cr = g[nodes->back()].char_reach;
@@ -260,7 +260,7 @@ void improveHead(NGHolder &g, NFAVertex *a, vector<NFAVertex> *nodes) {
}
static
void constructPuff(NGHolder &g, const NFAVertex a, const NFAVertex puffv,
void constructPuff(const NGHolder &g, const NFAVertex a, const NFAVertex puffv,
const CharReach &cr, const ReportID report, u32 width,
bool fixed_depth, bool unbounded, bool auto_restart,
RoseBuild &rose, ReportManager &rm,

View File

@@ -323,7 +323,7 @@ bool doUselessMergePass(NGHolder &g, som_type som, VertexInfoMap &infoMap,
bool changed = false;
for (auto v : vertices_range(g)) {
VertexInfo &info = infoMap[v];
const VertexInfo &info = infoMap[v];
if (info.isRemoved) {
continue;
@@ -439,7 +439,7 @@ bool doUselessMergePass(NGHolder &g, som_type som, VertexInfoMap &infoMap,
continue; // Conservatively skip anything with nonzero tops.
}
CharReach &otherReach = g[t].char_reach;
const CharReach &otherReach = g[t].char_reach;
if (currReach.isSubsetOf(otherReach)) {
DEBUG_PRINTF("removing redundant vertex %zu (keeping %zu)\n",
g[v].index, g[t].index);
@@ -745,7 +745,7 @@ u32 findCyclic(const NGHolder &g, vector<bool> &cyclic) {
}
static
void findCyclicDom(NGHolder &g, vector<bool> &cyclic,
void findCyclicDom(const NGHolder &g, vector<bool> &cyclic,
set<NFAEdge> &dead, som_type som) {
auto dominators = findDominators(g);
@@ -789,7 +789,7 @@ void findCyclicDom(NGHolder &g, vector<bool> &cyclic,
}
static
void findCyclicPostDom(NGHolder &g, vector<bool> &cyclic,
void findCyclicPostDom(const NGHolder &g, vector<bool> &cyclic,
set<NFAEdge> &dead) {
auto postdominators = findPostDominators(g);

View File

@@ -1874,7 +1874,7 @@ void buildFeeder(NGHolder &g, const BoundedRepeatData &rd,
* offset.
*/
static
bool improveLeadingRepeat(NGHolder &g, BoundedRepeatData &rd,
bool improveLeadingRepeat(NGHolder &g, const BoundedRepeatData &rd,
unordered_set<NFAVertex> &created,
const vector<BoundedRepeatData> &all_repeats) {
assert(edge(g.startDs, g.startDs, g).second);
@@ -1944,7 +1944,7 @@ bool improveLeadingRepeat(NGHolder &g, BoundedRepeatData &rd,
}
static
vector<NFAVertex> makeOwnStraw(NGHolder &g, BoundedRepeatData &rd,
vector<NFAVertex> makeOwnStraw(NGHolder &g, const BoundedRepeatData &rd,
const vector<NFAVertex> &straw) {
// Straw runs from startDs to our pos trigger.
assert(!straw.empty());

View File

@@ -1177,7 +1177,7 @@ void expandGraph(NGHolder &g, unordered_map<NFAVertex, u32> &regions,
}
static
bool doTreePlanningIntl(NGHolder &g,
bool doTreePlanningIntl(const NGHolder &g,
const unordered_map<NFAVertex, u32> &regions,
const map<u32, region_info> &info,
map<u32, region_info>::const_iterator picked, u32 bad_region,
@@ -1855,7 +1855,7 @@ bool doSomRevNfa(NG &ng, NGHolder &g, const CompileContext &cc) {
}
static
u32 doSomRevNfaPrefix(NG &ng, const ExpressionInfo &expr, NGHolder &g,
u32 doSomRevNfaPrefix(NG &ng, const ExpressionInfo &expr, const NGHolder &g,
const CompileContext &cc) {
depth maxWidth = findMaxWidth(g);
@@ -2011,7 +2011,7 @@ void setReportOnHaigPrefix(RoseBuild &rose, NGHolder &h) {
}
static
bool tryHaig(RoseBuild &rose, NGHolder &g,
bool tryHaig(RoseBuild &rose, const NGHolder &g,
const unordered_map<NFAVertex, u32> &regions,
som_type som, u32 somPrecision,
map<u32, region_info>::const_iterator picked,
@@ -2442,7 +2442,7 @@ void makeReportsSomPass(ReportManager &rm, NGHolder &g) {
}
static
bool doLitHaigSom(NG &ng, NGHolder &g, som_type som) {
bool doLitHaigSom(NG &ng, const NGHolder &g, som_type som) {
ue2_literal lit;
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
if (!rhs) {
@@ -2659,7 +2659,7 @@ bool doHaigLitHaigSom(NG &ng, NGHolder &g,
}
static
bool doMultiLitHaigSom(NG &ng, NGHolder &g, som_type som) {
bool doMultiLitHaigSom(NG &ng, const NGHolder &g, som_type som) {
set<ue2_literal> lits;
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
if (!ng.cc.grey.allowLitHaig) {

View File

@@ -112,7 +112,7 @@ bool forkVertex(NFAVertex v, NGHolder &g, vector<DepthMinMax> &depths,
}
*numNewVertices += predGroups.size();
for (auto &group : predGroups) {
for (const auto &group : predGroups) {
const depth &predDepth = group.first;
const vector<NFAEdge> &preds = group.second;

View File

@@ -454,8 +454,8 @@ void buildNfaMergeQueue(const vector<NGHolder *> &cluster,
}
}
NGHolder &g_i = *(cluster[ci]);
NGHolder &g_j = *(cluster[cj]);
const NGHolder &g_i = *(cluster[ci]);
const NGHolder &g_j = *(cluster[cj]);
if (!compatibleStarts(g_i, g_j)) {
continue;

View File

@@ -688,7 +688,7 @@ unique_ptr<VertLitInfo> findBestSplit(const NGHolder &g,
}
if (seeking_transient) {
for (auto &a : lits) {
for (const auto &a : lits) {
a->creates_transient
= createsTransientLHS(g, a->vv, *depths, cc.grey);
}
@@ -697,7 +697,7 @@ unique_ptr<VertLitInfo> findBestSplit(const NGHolder &g,
if (last_chance) {
const size_t num_verts = num_vertices(g);
auto color_map = make_small_color_map(g);
for (auto &a : lits) {
for (const auto &a : lits) {
size_t num_reachable = count_reachable(g, a->vv, color_map);
double ratio = (double)num_reachable / (double)num_verts;
a->split_ratio = ratio > 0.5 ? 1 - ratio : ratio;
@@ -1172,7 +1172,7 @@ bool splitRoseEdge(const NGHolder &base_graph, RoseInGraph &vg,
#define MAX_LEN_2_LITERALS_PER_CUT 3
static
bool checkValidNetflowLits(NGHolder &h, const vector<u64a> &scores,
bool checkValidNetflowLits(const NGHolder &h, const vector<u64a> &scores,
const map<NFAEdge, set<ue2_literal>> &cut_lits,
u32 min_allowed_length) {
DEBUG_PRINTF("cut width %zu; min allowed %u\n", cut_lits.size(),
@@ -1209,7 +1209,7 @@ bool checkValidNetflowLits(NGHolder &h, const vector<u64a> &scores,
}
static
void splitEdgesByCut(NGHolder &h, RoseInGraph &vg,
void splitEdgesByCut(const NGHolder &h, RoseInGraph &vg,
const vector<RoseInEdge> &to_cut,
const vector<NFAEdge> &cut,
const map<NFAEdge, set<ue2_literal>> &cut_lits) {
@@ -1805,7 +1805,7 @@ void removeRedundantLiterals(RoseInGraph &g, const CompileContext &cc) {
}
static
RoseInVertex getStart(RoseInGraph &vg) {
RoseInVertex getStart(const RoseInGraph &vg) {
for (RoseInVertex v : vertices_range(vg)) {
if (vg[v].type == RIV_START || vg[v].type == RIV_ANCHORED_START) {
return v;
@@ -1870,7 +1870,7 @@ unique_ptr<NGHolder> make_chain(u32 count) {
#define SHORT_TRIGGER_LEN 16
static
bool makeTransientFromLongLiteral(NGHolder &h, RoseInGraph &vg,
bool makeTransientFromLongLiteral(const NGHolder &h, RoseInGraph &vg,
const vector<RoseInEdge> &ee,
const CompileContext &cc) {
/* check max width and literal lengths to see if possible */
@@ -2150,7 +2150,7 @@ void findBetterPrefixes(RoseInGraph &vg, const CompileContext &cc) {
#define MAX_EXTRACT_STRONG_LITERAL_GRAPHS 10
static
bool extractStrongLiteral(NGHolder &h, RoseInGraph &vg,
bool extractStrongLiteral(const NGHolder &h, RoseInGraph &vg,
const vector<RoseInEdge> &ee,
const CompileContext &cc) {
DEBUG_PRINTF("looking for string literal\n");
@@ -2805,7 +2805,7 @@ bool tryForEarlyDfa(const NGHolder &h, const CompileContext &cc) {
}
static
vector<vector<CharReach>> getDfaTriggers(RoseInGraph &vg,
vector<vector<CharReach>> getDfaTriggers(const RoseInGraph &vg,
const vector<RoseInEdge> &edges,
bool *single_trigger) {
vector<vector<CharReach>> triggers;
@@ -2927,7 +2927,7 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
vector<RoseInEdge>> edges_by_graph;
for (const RoseInEdge &ve : edges_range(vg)) {
if (vg[ve].graph && !vg[ve].dfa) {
auto &h = vg[ve].graph;
const auto &h = vg[ve].graph;
edges_by_graph[h].emplace_back(ve);
}
}