ng_calc_components: rework to move graphs

Rather than cloning graphs for output, rework calc components so that it
moves them.
This commit is contained in:
Justin Viiret
2017-03-21 10:27:14 +11:00
committed by Matthew Barr
parent 5dfae12a62
commit ba867ebaff
6 changed files with 51 additions and 52 deletions

View File

@@ -276,13 +276,12 @@ void addExpression(NG &ng, unsigned index, const char *expression,
throw CompileError("Internal error.");
}
auto &g = *built_expr.g;
if (!pe.expr.allow_vacuous && matches_everywhere(g)) {
if (!pe.expr.allow_vacuous && matches_everywhere(*built_expr.g)) {
throw CompileError("Pattern matches empty buffer; use "
"HS_FLAG_ALLOWEMPTY to enable support.");
}
if (!ng.addGraph(built_expr.expr, g)) {
if (!ng.addGraph(built_expr.expr, std::move(built_expr.g))) {
DEBUG_PRINTF("NFA addGraph failed on ID %u.\n", pe.expr.report);
throw CompileError("Error compiling expression.");
}