From 29ad557b9cf1d502abfe7a2b2887ebea636903c3 Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Mon, 1 May 2017 13:31:09 +1000 Subject: [PATCH] smwr: more aggressive pruning of overlong paths in NFA --- src/smallwrite/smallwrite_build.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/smallwrite/smallwrite_build.cpp b/src/smallwrite/smallwrite_build.cpp index ba2f244d..43900207 100644 --- a/src/smallwrite/smallwrite_build.cpp +++ b/src/smallwrite/smallwrite_build.cpp @@ -198,15 +198,16 @@ static bool pruneOverlong(NGHolder &g, const depth &max_depth, const ReportManager &rm) { bool modified = false; - auto depths = calcDepths(g); + auto depths = calcBidiDepths(g); for (auto v : vertices_range(g)) { if (is_special(v, g)) { continue; } const auto &d = depths.at(g[v].index); - depth min_depth = min(d.fromStart.min, d.fromStartDotStar.min); - if (min_depth > max_depth) { + depth min_match_offset = min(d.fromStart.min, d.fromStartDotStar.min) + + min(d.toAccept.min, d.toAcceptEod.min); + if (min_match_offset > max_depth) { clear_vertex(v, g); modified = true; continue;