mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
ext param - more consistent depth check
This commit is contained in:
parent
1450dc9993
commit
090632f61a
@ -629,15 +629,6 @@ bool hasExtParams(const ExpressionInfo &expr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class VertexDepth>
|
||||
depth maxDistFromStart(const VertexDepth &d) {
|
||||
if (!d.fromStartDotStar.max.is_unreachable()) {
|
||||
// A path from startDs, any path, implies we can match at any offset.
|
||||
return depth::infinity();
|
||||
}
|
||||
return d.fromStart.max;
|
||||
}
|
||||
|
||||
static
|
||||
const depth& maxDistToAccept(const NFAVertexBidiDepth &d) {
|
||||
if (d.toAccept.max.is_unreachable()) {
|
||||
@ -689,7 +680,7 @@ bool isEdgePrunable(const NGHolder &g, const Report &report,
|
||||
const NFAVertexBidiDepth &dv = depths.at(v_idx);
|
||||
|
||||
if (report.minOffset) {
|
||||
depth max_offset = maxDistFromStart(du) + maxDistToAccept(dv);
|
||||
depth max_offset = maxDistFromStartOfData(du) + maxDistToAccept(dv);
|
||||
if (max_offset.is_finite() && max_offset < report.minOffset) {
|
||||
DEBUG_PRINTF("max_offset=%s too small\n", max_offset.str().c_str());
|
||||
return true;
|
||||
@ -709,7 +700,7 @@ bool isEdgePrunable(const NGHolder &g, const Report &report,
|
||||
if (report.minLength && is_any_accept(v, g)) {
|
||||
// Simple take on min_length. If we're an edge to accept and our max
|
||||
// dist from start is too small, we can be pruned.
|
||||
const depth &width = du.fromStart.max;
|
||||
const depth &width = maxDistFromInit(du);
|
||||
if (width.is_finite() && width < report.minLength) {
|
||||
DEBUG_PRINTF("max width %s from start too small for min_length\n",
|
||||
width.str().c_str());
|
||||
@ -961,7 +952,7 @@ void removeUnneededOffsetBounds(NGHolder &g, ReportManager &rm) {
|
||||
replaceReports(g, [&](NFAVertex v, ReportID id) {
|
||||
const auto &d = depths.at(g[v].index);
|
||||
const depth &min_depth = min(d.fromStartDotStar.min, d.fromStart.min);
|
||||
const depth &max_depth = maxDistFromStart(d);
|
||||
const depth &max_depth = maxDistFromStartOfData(d);
|
||||
|
||||
DEBUG_PRINTF("vertex %zu has min_depth=%s, max_depth=%s\n", g[v].index,
|
||||
min_depth.str().c_str(), max_depth.str().c_str());
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "ng_util.h"
|
||||
|
||||
#include "grey.h"
|
||||
#include "ng_depth.h" // for NFAVertexDepth
|
||||
#include "ng_dump.h"
|
||||
#include "ng_prune.h"
|
||||
#include "ue2common.h"
|
||||
@ -61,25 +60,6 @@ using boost::make_assoc_property_map;
|
||||
|
||||
namespace ue2 {
|
||||
|
||||
depth maxDistFromInit(const NFAVertexDepth &vd) {
|
||||
if (vd.fromStart.max.is_unreachable()) {
|
||||
return vd.fromStartDotStar.max;
|
||||
} else if (vd.fromStartDotStar.max.is_unreachable()) {
|
||||
return vd.fromStart.max;
|
||||
} else {
|
||||
return max(vd.fromStartDotStar.max, vd.fromStart.max);
|
||||
}
|
||||
}
|
||||
|
||||
depth maxDistFromStartOfData(const NFAVertexDepth &vd) {
|
||||
if (vd.fromStartDotStar.max.is_reachable()) {
|
||||
/* the irrepressible nature of floating literals cannot be contained */
|
||||
return depth::infinity();
|
||||
} else {
|
||||
return vd.fromStart.max;
|
||||
}
|
||||
}
|
||||
|
||||
NFAVertex getSoleDestVertex(const NGHolder &g, NFAVertex a) {
|
||||
assert(a != NGHolder::null_vertex());
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#ifndef NG_UTIL_H
|
||||
#define NG_UTIL_H
|
||||
|
||||
#include "ng_depth.h"
|
||||
#include "ng_holder.h"
|
||||
#include "ue2common.h"
|
||||
#include "util/flat_containers.h"
|
||||
@ -40,6 +41,7 @@
|
||||
|
||||
#include <boost/graph/depth_first_search.hpp> // for default_dfs_visitor
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@ -47,13 +49,29 @@
|
||||
namespace ue2 {
|
||||
|
||||
struct Grey;
|
||||
struct NFAVertexDepth;
|
||||
struct ue2_literal;
|
||||
class depth;
|
||||
class ReportManager;
|
||||
|
||||
depth maxDistFromInit(const NFAVertexDepth &d);
|
||||
depth maxDistFromStartOfData(const NFAVertexDepth &d);
|
||||
template<class VertexDepth>
|
||||
depth maxDistFromInit(const VertexDepth &vd) {
|
||||
if (vd.fromStart.max.is_unreachable()) {
|
||||
return vd.fromStartDotStar.max;
|
||||
} else if (vd.fromStartDotStar.max.is_unreachable()) {
|
||||
return vd.fromStart.max;
|
||||
} else {
|
||||
return std::max(vd.fromStartDotStar.max, vd.fromStart.max);
|
||||
}
|
||||
}
|
||||
|
||||
template<class VertexDepth>
|
||||
depth maxDistFromStartOfData(const VertexDepth &vd) {
|
||||
if (vd.fromStartDotStar.max.is_reachable()) {
|
||||
/* the irrepressible nature of floating literals cannot be contained */
|
||||
return depth::infinity();
|
||||
} else {
|
||||
return vd.fromStart.max;
|
||||
}
|
||||
}
|
||||
|
||||
/** True if the given vertex is a dot (reachable on any character). */
|
||||
template<class GraphT>
|
||||
|
Loading…
x
Reference in New Issue
Block a user