mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-10-01 20:17:42 +03:00
replace push_back by emplace_back where possible
This commit is contained in:
@@ -57,7 +57,7 @@ ComponentAlternation::ComponentAlternation(const ComponentAlternation &other)
|
||||
: Component(other) {
|
||||
for (const auto &c : other.children) {
|
||||
assert(c);
|
||||
children.push_back(unique_ptr<Component>(c->clone()));
|
||||
children.emplace_back(unique_ptr<Component>(c->clone()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void ComponentAlternation::accept(ConstComponentVisitor &v) const {
|
||||
}
|
||||
|
||||
void ComponentAlternation::append(unique_ptr<Component> component) {
|
||||
children.push_back(move(component));
|
||||
children.emplace_back(move(component));
|
||||
}
|
||||
|
||||
vector<PositionInfo> ComponentAlternation::first() const {
|
||||
|
@@ -94,11 +94,11 @@ void ComponentBoundary::notePositions(GlushkovBuildState & bs) {
|
||||
{
|
||||
PositionInfo epsilon(GlushkovBuildState::POS_EPSILON);
|
||||
epsilon.flags = POS_FLAG_NOFLOAT;
|
||||
m_first.push_back(epsilon);
|
||||
m_first.emplace_back(epsilon);
|
||||
|
||||
// We have the start vertex in firsts so that we can discourage
|
||||
// the mid-pattern use of boundaries.
|
||||
m_first.push_back(startState);
|
||||
m_first.emplace_back(startState);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -106,11 +106,11 @@ void ComponentBoundary::notePositions(GlushkovBuildState & bs) {
|
||||
{
|
||||
PositionInfo epsilon(GlushkovBuildState::POS_EPSILON);
|
||||
epsilon.flags = POS_FLAG_NOFLOAT;
|
||||
m_first.push_back(epsilon);
|
||||
m_first.emplace_back(epsilon);
|
||||
|
||||
// We have the start vertex in firsts so that we can discourage
|
||||
// the mid-pattern use of boundaries.
|
||||
m_first.push_back(startState);
|
||||
m_first.emplace_back(startState);
|
||||
|
||||
// Newline
|
||||
m_newline = makeNewline(bs);
|
||||
@@ -118,8 +118,8 @@ void ComponentBoundary::notePositions(GlushkovBuildState & bs) {
|
||||
builder.setAssertFlag(m_newline, POS_FLAG_VIRTUAL_START);
|
||||
PositionInfo nl(m_newline);
|
||||
nl.flags = POS_FLAG_MUST_FLOAT | POS_FLAG_FIDDLE_ACCEPT;
|
||||
m_first.push_back(nl);
|
||||
m_last.push_back(nl);
|
||||
m_first.emplace_back(nl);
|
||||
m_last.emplace_back(nl);
|
||||
recordPosBounds(m_newline, m_newline + 1);
|
||||
break;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ void ComponentBoundary::notePositions(GlushkovBuildState & bs) {
|
||||
PositionInfo epsilon(GlushkovBuildState::POS_EPSILON);
|
||||
epsilon.flags = POS_FLAG_WIRE_EOD | POS_FLAG_NO_NL_EOD |
|
||||
POS_FLAG_NO_NL_ACCEPT | POS_FLAG_ONLY_ENDS;
|
||||
m_first.push_back(epsilon);
|
||||
m_first.emplace_back(epsilon);
|
||||
break;
|
||||
}
|
||||
case END_STRING_OPTIONAL_LF: // end of data with optional LF ('$')
|
||||
@@ -136,7 +136,7 @@ void ComponentBoundary::notePositions(GlushkovBuildState & bs) {
|
||||
PositionInfo epsilon(GlushkovBuildState::POS_EPSILON);
|
||||
epsilon.flags = POS_FLAG_WIRE_EOD | POS_FLAG_WIRE_NL_EOD |
|
||||
POS_FLAG_NO_NL_ACCEPT | POS_FLAG_ONLY_ENDS;
|
||||
m_first.push_back(epsilon);
|
||||
m_first.emplace_back(epsilon);
|
||||
break;
|
||||
}
|
||||
case END_LINE: // multiline anchor: end of data or a newline
|
||||
@@ -144,7 +144,7 @@ void ComponentBoundary::notePositions(GlushkovBuildState & bs) {
|
||||
PositionInfo epsilon(GlushkovBuildState::POS_EPSILON);
|
||||
epsilon.flags = POS_FLAG_WIRE_EOD | POS_FLAG_WIRE_NL_EOD |
|
||||
POS_FLAG_WIRE_NL_ACCEPT | POS_FLAG_ONLY_ENDS;
|
||||
m_first.push_back(epsilon);
|
||||
m_first.emplace_back(epsilon);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@@ -177,7 +177,7 @@ void ComponentRepeat::notePositions(GlushkovBuildState &bs) {
|
||||
|
||||
// Each optional repeat has an epsilon at the end of its firsts list.
|
||||
for (u32 i = m_min; i < m_firsts.size(); i++) {
|
||||
m_firsts[i].push_back(GlushkovBuildState::POS_EPSILON);
|
||||
m_firsts[i].emplace_back(GlushkovBuildState::POS_EPSILON);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ ComponentSequence::ComponentSequence(const ComponentSequence &other)
|
||||
// Deep copy children.
|
||||
for (const auto &c : other.children) {
|
||||
assert(c);
|
||||
children.push_back(unique_ptr<Component>(c->clone()));
|
||||
children.emplace_back(unique_ptr<Component>(c->clone()));
|
||||
}
|
||||
if (other.alternation) {
|
||||
const ComponentAlternation &c = *other.alternation;
|
||||
@@ -117,7 +117,7 @@ void ComponentSequence::accept(ConstComponentVisitor &v) const {
|
||||
}
|
||||
|
||||
void ComponentSequence::addComponent(unique_ptr<Component> comp) {
|
||||
children.push_back(move(comp));
|
||||
children.emplace_back(move(comp));
|
||||
}
|
||||
|
||||
bool ComponentSequence::addRepeat(u32 min, u32 max,
|
||||
@@ -152,7 +152,7 @@ void ComponentSequence::finalize() {
|
||||
if (alternation) {
|
||||
addAlternation();
|
||||
assert(children.empty());
|
||||
children.push_back(move(alternation));
|
||||
children.emplace_back(move(alternation));
|
||||
alternation = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ vector<PositionInfo> ComponentSequence::first() const {
|
||||
if (firsts.empty()) {
|
||||
DEBUG_PRINTF("trivial empty sequence %zu\n", firsts.size());
|
||||
assert(children.empty());
|
||||
firsts.push_back(GlushkovBuildState::POS_EPSILON);
|
||||
firsts.emplace_back(GlushkovBuildState::POS_EPSILON);
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("%zu firsts\n", firsts.size());
|
||||
@@ -202,7 +202,7 @@ void epsilonVisit(vector<eps_info> *info, const vector<PositionInfo> &f) {
|
||||
continue;
|
||||
}
|
||||
|
||||
out.push_back(*it);
|
||||
out.emplace_back(*it);
|
||||
out.back().flags = flags;
|
||||
seen_flags.insert(flags);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ void applyEpsilonVisits(vector<PositionInfo> &lasts,
|
||||
|
||||
for (const auto &last : lasts) {
|
||||
for (const auto &e : eps_visits) {
|
||||
out.push_back(last);
|
||||
out.emplace_back(last);
|
||||
out.back().flags |= e.flags;
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ ComponentWordBoundary * ComponentWordBoundary::clone() const {
|
||||
|
||||
vector<PositionInfo> ComponentWordBoundary::first() const {
|
||||
vector<PositionInfo> firsts;
|
||||
firsts.push_back(position);
|
||||
firsts.emplace_back(position);
|
||||
return firsts;
|
||||
}
|
||||
|
||||
|
@@ -1145,20 +1145,20 @@ void UTF8ComponentClass::buildFollowSet(GlushkovBuildState &,
|
||||
vector<PositionInfo> UTF8ComponentClass::first(void) const {
|
||||
vector<PositionInfo> rv;
|
||||
if (single_pos != GlushkovBuildState::POS_UNINITIALIZED) {
|
||||
rv.push_back(single_pos);
|
||||
rv.emplace_back(single_pos);
|
||||
}
|
||||
if (two_char_dot_head != GlushkovBuildState::POS_UNINITIALIZED) {
|
||||
rv.push_back(two_char_dot_head);
|
||||
rv.emplace_back(two_char_dot_head);
|
||||
}
|
||||
if (three_char_dot_head != GlushkovBuildState::POS_UNINITIALIZED) {
|
||||
rv.push_back(three_char_dot_head);
|
||||
rv.emplace_back(three_char_dot_head);
|
||||
}
|
||||
if (four_char_dot_head != GlushkovBuildState::POS_UNINITIALIZED) {
|
||||
rv.push_back(four_char_dot_head);
|
||||
rv.emplace_back(four_char_dot_head);
|
||||
}
|
||||
|
||||
for (auto it = heads.begin(); it != heads.end(); ++it) {
|
||||
rv.push_back(it->second);
|
||||
rv.emplace_back(it->second);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@@ -155,9 +155,9 @@ GlushkovBuildStateImpl::GlushkovBuildStateImpl(NFABuilder &b,
|
||||
vector<PositionInfo> lasts, firsts;
|
||||
|
||||
// start->startDs and startDs self-loop.
|
||||
lasts.push_back(startState);
|
||||
lasts.push_back(startDotstarState);
|
||||
firsts.push_back(startDotstarState);
|
||||
lasts.emplace_back(startState);
|
||||
lasts.emplace_back(startDotstarState);
|
||||
firsts.emplace_back(startDotstarState);
|
||||
connectRegions(lasts, firsts);
|
||||
|
||||
// accept to acceptEod edges already wired
|
||||
@@ -255,7 +255,7 @@ void generateAccepts(GlushkovBuildStateImpl &bs, const PositionInfo &from,
|
||||
bool require_accept = !(flags & POS_FLAG_ONLY_ENDS);
|
||||
|
||||
if (require_eod) {
|
||||
tolist->push_back(bs.acceptEodState);
|
||||
tolist->emplace_back(bs.acceptEodState);
|
||||
}
|
||||
|
||||
if (require_nl_accept) {
|
||||
@@ -264,7 +264,7 @@ void generateAccepts(GlushkovBuildStateImpl &bs, const PositionInfo &from,
|
||||
bs.addSuccessor(newline, builder.getAccept());
|
||||
bs.acceptNlState = newline;
|
||||
}
|
||||
tolist->push_back(bs.acceptNlState);
|
||||
tolist->emplace_back(bs.acceptNlState);
|
||||
}
|
||||
|
||||
if (require_nl_eod) {
|
||||
@@ -273,11 +273,11 @@ void generateAccepts(GlushkovBuildStateImpl &bs, const PositionInfo &from,
|
||||
bs.addSuccessor(newline, builder.getAcceptEOD());
|
||||
bs.acceptNlEodState = newline;
|
||||
}
|
||||
tolist->push_back(bs.acceptNlEodState);
|
||||
tolist->emplace_back(bs.acceptNlEodState);
|
||||
}
|
||||
|
||||
if (require_accept) {
|
||||
tolist->push_back(bs.acceptState);
|
||||
tolist->emplace_back(bs.acceptState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ void cleanupPositions(vector<PositionInfo> &a) {
|
||||
|
||||
for (const auto &p : a) {
|
||||
if (seen.emplace(p.pos, p.flags).second) {
|
||||
out.push_back(p); // first encounter
|
||||
out.emplace_back(p); // first encounter
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -92,7 +92,7 @@ u32 ParsedLogical::logicalTreeAdd(u32 op, u32 left, u32 right) {
|
||||
lop.op = op;
|
||||
lop.lo = left;
|
||||
lop.ro = right;
|
||||
logicalTree.push_back(lop);
|
||||
logicalTree.emplace_back(lop);
|
||||
return lop.id;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ void ParsedLogical::combinationInfoAdd(UNUSED u32 ckey, u32 id, u32 ekey,
|
||||
ci.result = lkey_result;
|
||||
ci.min_offset = min_offset;
|
||||
ci.max_offset = max_offset;
|
||||
combInfoMap.push_back(ci);
|
||||
combInfoMap.emplace_back(ci);
|
||||
|
||||
DEBUG_PRINTF("ckey %u (id %u) -> lkey %u..%u, ekey=0x%x\n", ckey, ci.id,
|
||||
ci.start, ci.result, ci.ekey);
|
||||
@@ -251,7 +251,7 @@ void popOperator(vector<LogicalOperator> &op_stack, vector<u32> &subid_stack,
|
||||
left = subid_stack.back();
|
||||
subid_stack.pop_back();
|
||||
}
|
||||
subid_stack.push_back(pl.logicalTreeAdd(op_stack.back().op, left, right));
|
||||
subid_stack.emplace_back(pl.logicalTreeAdd(op_stack.back().op, left, right));
|
||||
op_stack.pop_back();
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ void ParsedLogical::parseLogicalCombination(unsigned id, const char *logical,
|
||||
}
|
||||
} else {
|
||||
if ((subid = fetchSubID(logical, digit, i)) != (u32)-1) {
|
||||
subid_stack.push_back(getLogicalKey(subid));
|
||||
subid_stack.emplace_back(getLogicalKey(subid));
|
||||
addRelateCKey(subid_stack.back(), ckey);
|
||||
}
|
||||
if (logical[i] == ' ') { // skip whitespace
|
||||
@@ -298,7 +298,7 @@ void ParsedLogical::parseLogicalCombination(unsigned id, const char *logical,
|
||||
lkey_start = subid_stack.back();
|
||||
}
|
||||
}
|
||||
op_stack.push_back(op);
|
||||
op_stack.emplace_back(op);
|
||||
} else {
|
||||
throw LocatedParseError("Unknown character");
|
||||
}
|
||||
@@ -309,7 +309,7 @@ void ParsedLogical::parseLogicalCombination(unsigned id, const char *logical,
|
||||
throw LocatedParseError("Not enough right parentheses");
|
||||
}
|
||||
if ((subid = fetchSubID(logical, digit, i)) != (u32)-1) {
|
||||
subid_stack.push_back(getLogicalKey(subid));
|
||||
subid_stack.emplace_back(getLogicalKey(subid));
|
||||
addRelateCKey(subid_stack.back(), ckey);
|
||||
}
|
||||
while (!op_stack.empty()) {
|
||||
|
Reference in New Issue
Block a user