Skip to content

Commit 1928e4a

Browse files
committed
only dedup problematic but easily checkable edges
Most of the dups are in epsilons and fates, with occasional codepoints. Since it's more difficult to check the values for fancy edges, and not worth it anyway, just check simple edges.
1 parent a32de0c commit 1928e4a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/QRegex/NFA.nqp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -859,17 +859,19 @@ class QRegex::NFA {
859859
# a small O(N^2) dup remover
860860
$e := 3;
861861
while $e < $eend {
862-
my $f := 0;
863-
while $f < $e {
864-
# in order of likelihood of differences, hopefully
865-
if $edges[$e] != $EDGE_CHARLIST && $edges[$e] != $EDGE_CHARLIST_NEG && $edges[$e+2] == $edges[$f+2] && $edges[$e] == $edges[$f] && $edges[$e+1] == $edges[$f+1] {
866-
nqp::printfh($err, "Deleting dup edge at $s $e/$f\n") if $nfadeb;
867-
$f := $e;
868-
nqp::splice($edges,[],$e,3);
869-
$e := $e - 3;
870-
$eend := $eend - 3;
862+
my int $act := nqp::bitand_i($edges[$e], 0xff);
863+
if $act < $EDGE_CHARLIST {
864+
my $f := 0;
865+
while $f < $e {
866+
if $act == $edges[$f] && $edges[$e+2] == $edges[$f+2] && $edges[$e+1] == $edges[$f+1] {
867+
nqp::printfh($err, "Deleting dup edge at $s $e/$f\n") if $nfadeb;
868+
$f := $e;
869+
nqp::splice($edges,[],$e,3);
870+
$e := $e - 3;
871+
$eend := $eend - 3;
872+
}
873+
$f := $f + 3;
871874
}
872-
$f := $f + 3;
873875
}
874876
$e := $e + 3;
875877
}

0 commit comments

Comments
 (0)