]> perl5.git.perl.org Git - perl5.git/commitdiff This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mk_invlists: Look for a DFA optimization possibility
authorKarl Williamson <[email protected]>
Wed, 16 Apr 2025 04:52:31 +0000 (22:52 -0600)
committerKarl Williamson <[email protected]>
Sun, 20 Apr 2025 19:11:51 +0000 (13:11 -0600)
If both branches of an else lead to the same result, skip the else and
set the result unconditionally.  That's what this commit does for DFAs
that get the same value if they succeed as when they don't.

There is one current case where the DFA can return an anomalous result,
so it can't be optimized out.  Add a field to the hash entry defining
that entry, so it doesn't get optimized.

charclass_invlists.inc
regen/mk_invlists.pl

index a0aa34728604c4edd0ba30a2adf57fdcd61f7998..ea0d36f4dfdb58cd394ffdf324ca4be5930190fc 100644 (file)
@@ -193183,8 +193183,8 @@ static const U8 LB_table[61][61] = {
 //       28    21     6 20     13  9 13  6  28  21  13     12a       9  22      24  24  13  21  13     28         28  13      21 13 12       28 21    22 13           6  6 21 23 30 24 24 19     7 13 11  7   9 3
 /* B2*/ { 1, 0, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  1,  1,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //          17 21     6 20     13  9 13  6      21  13     12a       9  22              13  21  13                    13      21 13 12          21    22 13           6  6 21             19     7 13 11  7   9 3
-/* BA*/ {11,11, 0,11, 0, 1, 11, 0, 0, 0, 0, 11,  0,  0, 11, 11, 11,  0,  8, 11, 11, 11,  0,  0,  0,11, 11, 11,11, 11,  0, 11,  0, 0,11,11,11,11, 0,11, 8, 0,11,11,11, 0, 0, 0,11,11,11,11, 0,11, 0, 0, 0, 0,  0,1,0 },
-//       21 21 21 21  6 20  21 13  9 13  6  21  21  13  21  21  21   9  21  21  21  21  13  21  13 21  21  21 21  21  13  21  21 13 21 21 21 21 21 21 21 13 21 21 21  6  6 21 21 21 21 21 19 21  7 13 11  7   9 3
+/* BA*/ { 8, 8, 0, 8, 0, 1,  8, 0, 0, 0, 0,  8,  0,  0,  8,  8,  8,  0,  0,  8,  8,  8,  0,  0,  0, 8,  8,  8, 8,  8,  0,  8,  0, 0, 8, 8, 8, 8, 0, 8, 0, 0, 8, 8, 8, 0, 0, 0, 8, 8, 8, 8, 0, 8, 0, 0, 0, 0,  0,1,0 },
+//       21 21 21 21  6 20  21 13  9 13  6  21  21  13  21  21  21   9  22  21  21  21  13  21  13 21  21  21 21  21  13  21  21 13 21 21 21 21 21 21 22 13 21 21 21  6  6 21 21 21 21 21 19 21  7 13 11  7   9 3
 /* BB*/ { 0, 0, 0, 0, 0, 1,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,1,0 },
 //       21 21 21 21  6 20  21 13  9 13  6  21  21  13  21 12a  21   9  21  21  21  21  13  21  13 21  21  21 21  21  13  21  21 13 12 21 21 21 21 21 21 13 21 21 21  6  6 21 21 21 21 21 19 21  7 13 11  7   9 3
 /* BK*/ { 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1, 1,  1,  1, 1,  1,  1,  1,  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  1,1,0 },
@@ -193193,19 +193193,19 @@ static const U8 LB_table[61][61] = {
 //       20 20 20 20  6 20  20 13  9 13  6  20  20  13  20 12a  20   9  20  20  20  20  13  20  13 20  20  20 20  20  13  20  20 13 12 20 20 20 20 20 20 13 20 20 20  6  6 20 20 20 20 20 19 20  7 13 11  7   9 3
 /*CEE*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  0,  1,  0,  0,  0, 1,  1,  1, 0,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22     23a      13  21  13            30      13      21 13 12          21    22 13           6  6 21       23    19     7 13 11  7   9 3
-/* CL*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1, 14, 14,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1,14,14, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/* CL*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1, 11, 11,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1,11,11, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22      25  25  13  16  13                    13      16 13 12          21    22 13           6  6 16       25 25 19     7 13 11  7   9 3
 /* CM*/ { 5, 5, 2, 5, 0, 5,  5, 2, 2, 2, 0,  5,  2,  2,  5,  2,  5,  2,  2,  5,  5,  5,  2,  2,  2, 5,  5,  5, 5,  5,  2,  5,  2, 2, 2, 5, 5, 5, 2, 5, 2, 2, 5, 5, 5, 0, 0, 2, 5, 5, 5, 5, 2, 5, 0, 2, 2, 0,  2,1,0 },
 //        9  9  9  9  6  9   9  9  9  9  6   9   9   9   9   9   9   9   9   9   9   9   9   9   9  9   9   9  9   9   9   9   9  9  9  9  9  9  9  9  9  9  9  9  9  6  6  9  9  9  9  9  9  9  7  9  9  7   9 3
-/* CP*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1, 14, 14,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,14,14, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/* CP*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1, 11, 11,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,11,11, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       30    21     6 20     13  9 13  6  30  21  13     12a       9  22      25  25  13  16  13     30         30  13      16 13 12       30 21    22 13           6  6 16 30    25 25 19     7 13 11  7   9 3
 /* CR*/ { 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1, 1,  1,  1, 1,  1,  1,  1,  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  1,1,0 },
 //        5  5  5  5  5  5   5  5  5  5  5   5   5   5   5   5   5   5   5   5   5   5   5   5   5  5   5   5  5   5   5   5   5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5   5 3
 /*EAA*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1,  0,  0,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       28    21     6 20     13  9 13  6  28  21  13     12a       9  22      24  24  13  21  13     28         28  13      21 13 12       28 21    22 13           6  6 21 23 30 24 24 19     7 13 11  7   9 3
-/*EAB*/ {11,11, 0,11, 0, 1, 11, 0, 0, 0, 0, 11,  0,  0, 11, 11, 11,  0,  8, 11, 11, 11,  0,  0,  0,11, 11, 11,11, 11,  0, 11,  0, 0,11,11,11,11, 0,11, 8, 0,11,11,11, 0, 0, 0,11,11,11,11, 0,11, 0, 0, 0, 0,  0,1,0 },
-//       21 21 21 21  6 20  21 13  9 13  6  21  21  13  21  21  21   9  21  21  21  21  13  21  13 21  21  21 21  21  13  21  21 13 21 21 21 21 21 21 21 13 21 21 21  6  6 21 21 21 21 21 19 21  7 13 11  7   9 3
-/*EAC*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1, 14, 14,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1,14,14, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/*EAB*/ { 8, 8, 0, 8, 0, 1,  8, 0, 0, 0, 0,  8,  0,  0,  8,  8,  8,  0,  0,  8,  8,  8,  0,  0,  0, 8,  8,  8, 8,  8,  0,  8,  0, 0, 8, 8, 8, 8, 0, 8, 0, 0, 8, 8, 8, 0, 0, 0, 8, 8, 8, 8, 0, 8, 0, 0, 0, 0,  0,1,0 },
+//       21 21 21 21  6 20  21 13  9 13  6  21  21  13  21  21  21   9  22  21  21  21  13  21  13 21  21  21 21  21  13  21  21 13 21 21 21 21 21 21 22 13 21 21 21  6  6 21 21 21 21 21 19 21  7 13 11  7   9 3
+/*EAC*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1, 11, 11,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1,11,11, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22      25  25  13  16  13                    13      16 13 12          21    22 13           6  6 16       25 25 19     7 13 11  7   9 3
 /*EAE*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  0,  1,  0,  0,  0, 1,  1,  1, 0,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22     23a      13  21  13            30      13      21 13 12          21    22 13           6  6 21       23    19     7 13 11  7   9 3
@@ -193219,11 +193219,11 @@ static const U8 LB_table[61][61] = {
 //             21     6 20     13  9 13  6      21  13     12a       9  22              13  21  13                    13      21 13 12          21    22 13           6  6 21             19     7 13 11  7   9 3
 /*EAO*/ { 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,1,0 },
 //       14 14 14 14  6 14  14 13  9 13  6  14  14  13  14 12a  14   9  14  14  14  14  13  14  13 14  14  14 14  14  13  14  14 13 12 14 14 14 14 14 14 13 14 14 14  6  6 14 14 14 14 14 14 14  7 13 11  7   9 3
-/*EAP*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0, 20,  1,  1,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,20, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/*EAP*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0, 17,  1,  1,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,17, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       24    21     6 20     13  9 13  6  24  21  13     12a       9  22  25          13  21  13     24         24  13      21 13 12       24 21    22 13           6  6 21 25 25       19     7 13 11  7   9 3
-/*EAR*/ { 0, 1, 0, 1, 0, 1,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  1,  1,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,20, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/*EAR*/ { 0, 1, 0, 1, 0, 1,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  1,  1,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       24    21     6 20 23a 13  9 13  6  24  21  13 23a 12a 23a   9  22  25          13  21  13 23  24 23a 23  24  13 23a  21 13 12 27 27 24 21 23 22 13 27 27 27  6  6 21 25 25       19     7 13 11  7   9 3
-/*EAS*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1, 14, 14,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0,17, 1,14,14, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/*EAS*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1, 11, 11,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0,14, 1,11,11, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       29    21     6 20     13  9 13  6  29  21  13     12a       9  22      25  25  13  21  13     29         29  13      21 13 12       29 21    22 13           6  6 21 25    25 25 19     7 13 11  7   9 3
 /*EAT*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  1,  1,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22              13  21  13                    13      21 13 12          21    22 13           6  6 21             19     7 13 11  7   9 3
@@ -193255,13 +193255,13 @@ static const U8 LB_table[61][61] = {
 //             21     6 20     13  9 13  6      21  13     12a       9  22      27      13  21  13                    13      21 13 12          21    22 13    26     6  6 21       27    19     7 13 11  7   9 3
 /* HL*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1,  0,  0,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       28    21     6 20     13  9 13  6  28  21  13     12a       9  22      24  24  13  21  13     28         28  13      21 13 12       28 21    22 13           6  6 21 23 30 24 24 19     7 13 11  7   9 3
-/* HY*/ {11,11, 0,11, 0, 1, 11, 0, 0, 0, 0, 11,  0,  0, 11, 11, 11,  0,  8, 11, 11, 11,  0,  0,  0,11, 11, 11,11, 11,  0, 11,  0, 0,11,11,11,11, 0,11, 8, 0,11,11,11, 0, 0, 0, 8,11,11,11, 0,11, 0, 0, 0, 0,  0,1,0 },
-//       21 21 21 21  6 20  21 13  9 13  6  21  21  13  21  21  21   9  21  21  21  21  13  21  13 21  21  21 21  21  13  21  21 13 21 21 21 21 21 21 21 13 21 21 21  6  6 21 21 21 21 21 19 21  7 13 11  7   9 3
+/* HY*/ { 8, 8, 0, 8, 0, 1,  8, 0, 0, 0, 0,  8,  0,  0,  8,  8,  8,  0,  0,  8,  8,  8,  0,  0,  0, 8,  8,  8, 8,  8,  0,  8,  0, 0, 8, 8, 8, 8, 0, 8, 0, 0, 8, 8, 8, 0, 0, 0, 0, 8, 8, 8, 0, 8, 0, 0, 0, 0,  0,1,0 },
+//       21 21 21 21  6 20  21 13  9 13  6  21  21  13  21  21  21   9  22  21  21  21  13  21  13 21  21  21 21  21  13  21  21 13 21 21 21 21 21 21 22 13 21 21 21  6  6 21 25 21 21 21 19 21  7 13 11  7   9 3
 /* ID*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  0,  1,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22     23a      13  21  13                    13      21 13 12          21    22 13           6  6 21       23    19     7 13 11  7   9 3
 /* IN*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  1,  1,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22              13  21  13                    13      21 13 12          21    22 13           6  6 21             19     7 13 11  7   9 3
-/* IS*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1, 14, 14,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0,17, 1,14,14, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/* IS*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0,  1, 11, 11,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0,14, 1,11,11, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       29    21     6 20     13  9 13  6  29  21  13     12a       9  22      25  25  13  21  13     29         29  13      21 13 12       29 21    22 13           6  6 21 25    25 25 19     7 13 11  7   9 3
 /* JL*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  0,  1,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22      27      13  21  13                    13      21 13 12 26 26    21    22 13 26    26  6  6 21       27    19     7 13 11  7   9 3
@@ -193279,17 +193279,17 @@ static const U8 LB_table[61][61] = {
 //       23    21     6 20     13  9 13  6  23  21  13     12a       9  22      25  25  13  21  13     23         23  13      21 13 12       23 21    22 13           6  6 21 25 30 25 25 19     7 13 11  7   9 3
 /* OP*/ { 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,1,0 },
 //       14 14 14 14  6 14  14 13  9 13  6  14  14  13  14 12a  14   9  14  14  14  14  13  14  13 14  14  14 14  14  13  14  14 13 12 14 14 14 14 14 14 13 14 14 14  6  6 14 14 14 14 14 14 14  7 13 11  7   9 3
-/* PO*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0, 20,  1,  1,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,20, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/* PO*/ { 0, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  0,  0,  0,  1,  0,  1,  0,  0, 17,  1,  1,  0,  0,  0, 1,  0,  1, 1,  0,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,17, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       24    21     6 20     13  9 13  6  24  21  13     12a       9  22  25          13  21  13     24         24  13      21 13 12       24 21    22 13           6  6 21 25 25       19     7 13 11  7   9 3
-/* PR*/ { 0, 1, 0, 1, 0, 1,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  1,  1,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,20, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/* PR*/ { 0, 1, 0, 1, 0, 1,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0, 17,  1,  1,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 1, 1, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //       24    21     6 20 23a 13  9 13  6  24  21  13 23a 12a 23a   9  22  25          13  21  13 23  24 23a 23  24  13 23a  21 13 12 27 27 24 21 23 22 13 27 27 27  6  6 21 25 25       19     7 13 11  7   9 3
 /* QU*/ { 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,1,0 },
 //       19 19 19 19  6 19  19 13  9 13  6  19  19  13  19 12a  19   9  19  15  19  19  13  19  13 19  19  19 19  19  13  19  19 13 12 19 19 19 19 19 19 13 19 19 19  6  6 19 19 15 19 19 19 19  7 13 11  7   9 3
-/* RI*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  1,  1,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0,26, 0, 0, 0, 0,  0,1,0 },
+/* RI*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1,  1,  1,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0,23, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22              13  21  13                    13      21 13 12          21    22 13           6  6 21             19 30  7 13 11  7   9 3
-/* SP*/ {29,34,29,29, 0,29, 29,23,29,23, 0, 29, 29, 23, 29, 29, 29, 29, 29, 48, 29, 29, 23, 41, 23,29, 29, 29,29, 29, 23, 29, 41,23,29,29,29,29,29,29,29,23,29,29,29, 0, 0,41,29,48,29,29,29,29, 0,23,23, 0, 29,1,0 },
+/* SP*/ {26,31,26,26, 0,26, 26,20,26,20, 0, 26, 26, 20, 26, 26, 26, 26, 26, 45, 26, 26, 20, 38, 20,26, 26, 26,26, 26, 20, 26, 38,20,26,26,26,26,26,26,26,20,26,26,26, 0, 0,38,26,45,26,26,26,26, 0,20,20, 0, 26,1,0 },
 //        8  8  8  8  6  8   8  8  8  8  6   8   8   8   8   8   8   8   8   8   8   8   8   8   8  8   8   8  8   8   8   8   8  8  8  8  8  8  8  8  8  8  8  8  8  6  6  8  8  8  8  8  8  8  7  8  8  7   8 3
-/* SY*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1, 14, 14,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0,17, 1,14,14, 0, 1, 0, 0, 0, 0,  0,1,0 },
+/* SY*/ { 1, 1, 0, 1, 0, 1,  1, 0, 0, 0, 0,  1,  0,  0,  1,  0,  1,  0,  0,  1, 11, 11,  0,  0,  0, 1,  1,  1, 1,  1,  0,  1,  0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0,14, 1,11,11, 0, 1, 0, 0, 0, 0,  0,1,0 },
 //             21     6 20     13  9 13  6      21  13     12a       9  22      25  25  13  21  13                    13      21 13 12       21 21    22 13           6  6 21 25    25 25 19     7 13 11  7   9 3
 /* WJ*/ { 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0,  0,  0, 0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,1,0 },
 //       11 11 11 11  6 11  11 11  9 11  6  11  11  11  11  11  11   9  11  11  11  11  11  11  11 11  11  11 11  11  11  11  11 11 11 11 11 11 11 11 11 11 11 11 11  6  6 11 11 11 11 11 11 11  7 11 11  7   9 3
@@ -193315,45 +193315,42 @@ static const U8 LB_dfa_table[] = {
     1, /*      else return 1  (Rules LB20,31) */
     13,        /* [8] LB_HL_then_HY_or_BA_v_any (Rule LB21) */
     0, /*      if matches, return 0 */
-    0, /*      else return 0  (Rules LB22,25) */
-    13,        /* [11] LB_HL_then_HY_or_BA_v_any (Rule LB21) */
-    0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB31) */
-    32,        /* [14] LB_NU_then_SY_or_IS_then_CL_or_CP_v_PO_or_PR (Rule LB25) */
+    32,        /* [11] LB_NU_then_SY_or_IS_then_CL_or_CP_v_PO_or_PR (Rule LB25) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB31) */
-    11,        /* [17] LB_NU_then_SY_or_IS_v_various (Rule LB25) */
+    11,        /* [14] LB_NU_then_SY_or_IS_v_various (Rule LB25) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB31) */
-    9, /* [20] LB_PR_or_PO_v_OP_or_HY_then_NU (Rule LB25) */
+    9, /* [17] LB_PR_or_PO_v_OP_or_HY_then_NU (Rule LB25) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB31) */
-    6, /* [23] LB_ZW_then_SP_v_any (Rule LB8) */
+    6, /* [20] LB_ZW_then_SP_v_any (Rule LB8) */
     1, /*      if matches, return 1 */
     0, /*      else return 0  (Rules LB11,13) */
-    15,        /* [26] LB_various_then_RI_v_RI (Rule LB30a) */
+    15,        /* [23] LB_various_then_RI_v_RI (Rule LB30a) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB31) */
-    6, /* [29] LB_ZW_then_SP_v_any (Rule LB8) */
+    6, /* [26] LB_ZW_then_SP_v_any (Rule LB8) */
     1, /*      if matches, return 1 */
     16,        /*      else try LB_OP_then_SP_v_any (Rule LB14) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB18) */
-    6, /* [34] LB_ZW_then_SP_v_any (Rule LB8) */
+    6, /* [31] LB_ZW_then_SP_v_any (Rule LB8) */
     1, /*      if matches, return 1 */
     16,        /*      else try LB_OP_then_SP_v_any (Rule LB14) */
     0, /*      if matches, return 0 */
     19,        /*      else try LB_B2_then_SP_v_B2 (Rule LB17) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB18) */
-    6, /* [41] LB_ZW_then_SP_v_any (Rule LB8) */
+    6, /* [38] LB_ZW_then_SP_v_any (Rule LB8) */
     1, /*      if matches, return 1 */
     16,        /*      else try LB_OP_then_SP_v_any (Rule LB14) */
     0, /*      if matches, return 0 */
     18,        /*      else try LB_CL_or_CP_then_SP_v_NS (Rule LB16) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule LB18) */
-    6, /* [48] LB_ZW_then_SP_v_any (Rule LB8) */
+    6, /* [45] LB_ZW_then_SP_v_any (Rule LB8) */
     1, /*      if matches, return 1 */
     16,        /*      else try LB_OP_then_SP_v_any (Rule LB14) */
     0, /*      if matches, return 0 */
@@ -193444,43 +193441,43 @@ static const U8 WB_table[23][23] = {
 //          3b                 4  4    3b       3b          3b            4 1
 /* CR*/ { 1, 0, 1,  1,  1, 1,  1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,  1,1,0 },
 //       3a  3 3a  3a  3a 3a  3a 3a 3a  3 3a 3a  3 3a 3a 3a  3 3a 3a 3a  3a 1
-/* DQ*/ { 1, 1, 1,  1,  1, 1,  0, 0,14, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  0,1,0 },
+/* DQ*/ { 1, 1, 1,  1,  1, 1,  0, 0,11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  0,1,0 },
 //          3b                 4  4 7c 3b       3b          3b            4 1
-/*EPL*/ { 1, 1, 1,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1, 8, 8, 1, 1, 0, 1, 8,  0,1,0 },
+/*EPL*/ { 1, 1, 1,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1, 5, 5, 1, 1, 0, 1, 5,  0,1,0 },
 //          3b      5     13   4  4  5 3b     5 3b  6  6    3b  9     6   4 1
 /*EPX*/ { 1, 1, 1,  1,  1, 1,  0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  0,1,0 },
 //          3b                 4  4    3b       3b          3b            4 1
 /* EX*/ { 1, 1, 1,  0,  1, 0,  0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1,  0,1,0 },
 //          3b    13b     13   4  4 13 3b 13 13 3b          3b 13         4 1
-/*Ext*/ {11, 1,11, 11, 11,11,  0, 0,11, 1,11,11, 1,11,11,11, 1,11,11,11,  0,1,0 },
+/*Ext*/ { 8, 1, 8,  8,  8, 8,  0, 0, 8, 1, 8, 8, 1, 8, 8, 8, 1, 8, 8, 8,  0,1,0 },
 //        4 3b  4   4   4  4   4  4  4 3b  4  4 3b  4  4  4 3b  4  4  4   4 1
-/* FO*/ {11, 1,11, 11, 11,11,  0, 0,11, 1,11,11, 1,11,11,11, 1,11,11,11,  0,1,0 },
+/* FO*/ { 8, 1, 8,  8,  8, 8,  0, 0, 8, 1, 8, 8, 1, 8, 8, 8, 1, 8, 8, 8,  0,1,0 },
 //        4 3b  4   4   4  4   4  4  4 3b  4  4 3b  4  4  4 3b  4  4  4   4 1
-/* HL*/ { 1, 1,17,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1, 8, 8, 1, 1, 0, 1, 5,  0,1,0 },
-//          3b 7b   5     13   4  4  5 3b     5 3b  6  6    3b  9     6   4 1
-/* hs*/ { 1, 0, 1,  1,  1, 1,  0, 0, 1,26, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,  0,1,0 },
+/* HL*/ { 1, 1,14,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1, 5, 5, 1, 1, 0, 1, 0,  0,1,0 },
+//          3b 7b   5     13   4  4  5 3b     5 3b  6  6    3b  9    7a   4 1
+/* hs*/ { 1, 0, 1,  1,  1, 1,  0, 0, 1,23, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,  0,1,0 },
 //       3a  3 3a  3a  3a 3a  2z 2z 3a 2z 3a 3a  3 3a 3a 3a  3 3a 3a 3a  2z 1
 /* KA*/ { 1, 1, 1,  1,  1, 0,  0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,  0,1,0 },
 //          3b            13   4  4    3b 13    3b          3b            4 1
-/* LE*/ { 1, 1, 1,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1, 8, 8, 1, 1, 0, 1, 8,  0,1,0 },
+/* LE*/ { 1, 1, 1,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1, 5, 5, 1, 1, 0, 1, 5,  0,1,0 },
 //          3b      5     13   4  4  5 3b     5 3b  6  6    3b  9     6   4 1
 /* LF*/ { 1, 0, 1,  1,  1, 1,  1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,  1,1,0 },
 //       3a  3 3a  3a  3a 3a  3a 3a 3a  3 3a 3a  3 3a 3a 3a  3 3a 3a 3a  3a 1
-/* MB*/ { 1, 1, 1,  2,  1, 1,  0, 0, 2, 1, 1, 2, 1, 1, 1, 1, 1,20, 1, 1,  0,1,0 },
+/* MB*/ { 1, 1, 1,  2,  1, 1,  0, 0, 2, 1, 1, 2, 1, 1, 1, 1, 1,17, 1, 1,  0,1,0 },
 //          3b      7          4  4  7 3b     7 3b          3b 11         4 1
 /* ML*/ { 1, 1, 1,  2,  1, 1,  0, 0, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,  0,1,0 },
 //          3b      7          4  4  7 3b     7 3b          3b            4 1
-/* MN*/ { 1, 1, 1,  1,  1, 1,  0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,20, 1, 1,  0,1,0 },
+/* MN*/ { 1, 1, 1,  1,  1, 1,  0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,17, 1, 1,  0,1,0 },
 //          3b                 4  4    3b       3b          3b 11         4 1
 /* NL*/ { 1, 0, 1,  1,  1, 1,  1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,  1,1,0 },
 //       3a  3 3a  3a  3a 3a  3a 3a 3a  3 3a 3a  3 3a 3a 3a  3 3a 3a 3a  3a 1
-/* NU*/ { 1, 1, 1,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1,23, 1,23, 1, 0, 1,23,  0,1,0 },
+/* NU*/ { 1, 1, 1,  0,  1, 0,  0, 0, 0, 1, 1, 0, 1,20, 1,20, 1, 0, 1,20,  0,1,0 },
 //          3b     10     13   4  4 10 3b    10 3b 12    12 3b  8    12   4 1
-/* RI*/ { 1, 1, 1,  1,  1, 1,  0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,29, 1,  0,1,0 },
+/* RI*/ { 1, 1, 1,  1,  1, 1,  0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,26, 1,  0,1,0 },
 //          3b                 4  4    3b       3b          3b    15      4 1
-/* SQ*/ { 1, 1, 1,  2,  1, 1,  0, 0, 2, 1, 1, 2, 1, 1, 1, 1, 1,20, 1, 1,  0,1,0 },
+/* SQ*/ { 1, 1, 1,  2,  1, 1,  0, 0, 2, 1, 1, 2, 1, 1, 1, 1, 1,17, 1, 1,  0,1,0 },
 //          3b      7          4  4  7 3b     7 3b          3b 11         4 1
-/*ZWJ*/ {11, 1,11,  0,  0,11,  0, 0,11, 1,11,11, 1,11,11,11, 1,11,11,11,  0,1,0 },
+/*ZWJ*/ { 8, 1, 8,  0,  0, 8,  0, 0, 8, 1, 8, 8, 1, 8, 8, 8, 1, 8, 8, 8,  0,1,0 },
 //        4 3b  4  3c  3c  4   4  4  4 3b  4  4 3b  4  4  4 3b  4  4  4   4 1
 /* ^ */ { 1, 1, 1,  1,  1, 1,  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  1,0,0 },
 //        2  2  2   2   2  2   2  2  2  2  2  2  2  2  2  2  2  2  2  2   2 1
@@ -193497,29 +193494,26 @@ static const U8 WB_dfa_table[] = {
     1, /*      else return 1  (Rule WB99) */
     8, /* [5] WB_AHL_v_ML_or_MNLQ_then_AHL (Rule WB6) */
     0, /*      if matches, return 0 */
-    0, /*      else return 0  (Rule WB7) */
-    8, /* [8] WB_AHL_v_ML_or_MNLQ_then_AHL (Rule WB6) */
-    0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule WB99) */
-    3, /* [11] WB_Extend_or_FO_or_ZWJ_then_foo (Rule WB4) */
+    3, /* [8] WB_Extend_or_FO_or_ZWJ_then_foo (Rule WB4) */
     255,       /*      if matches, return 255 */
     1, /*      else return 1  (Rule WB99) */
-    4, /* [14] WB_HL_then_DQ_v_HL (Rule WB7c) */
+    4, /* [11] WB_HL_then_DQ_v_HL (Rule WB7c) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule WB99) */
-    6, /* [17] WB_HL_v_DQ_then_HL (Rule WB7b) */
+    6, /* [14] WB_HL_v_DQ_then_HL (Rule WB7b) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule WB99) */
-    12,        /* [20] WB_NU_then_MN_or_MNLQ_v_NU (Rule WB11) */
+    12,        /* [17] WB_NU_then_MN_or_MNLQ_v_NU (Rule WB11) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule WB99) */
-    14,        /* [23] WB_NU_v_MN_or_MNLQ_then_NU (Rule WB12) */
+    14,        /* [20] WB_NU_v_MN_or_MNLQ_then_NU (Rule WB12) */
     0, /*      if matches, return 0 */
     1, /*      else return 1  (Rule WB99) */
-    2, /* [26] WB_hs_v_hs_then_Extend_or_FO_or_ZWJ (Rule WB2z) */
+    2, /* [23] WB_hs_v_hs_then_Extend_or_FO_or_ZWJ (Rule WB2z) */
     1, /*      if matches, return 1 */
     0, /*      else return 0  (Rule WB2) */
-    16,        /* [29] WB_various_then_RI_v_RI (Rules WB15, WB16) */
+    16,        /* [26] WB_various_then_RI_v_RI (Rules WB15, WB16) */
     0, /*      if matches, return 0 */
     1  /*      else return 1  (Rule WB99) */
 };
index f0a702f8c484c39182d164634689396d5859f9f8..99d7184fc868a0a408a609376d8a78dacf65480a 100644 (file)
@@ -1747,9 +1747,32 @@ sub output_table_common($property, $dfas_ref, $table_ref, $short_names_ref,
             # XXX and [1] is the value to return if the corresponding dfa matches.
             my @values = $value->@*;
 
+            # There is generally no point in pursuing a dfa if its matching
+            # value is the same as what is returned if it doesn't match.
+            # There may be cases where the runtime decision varies, so
+            # shouldn't be optimized out.  The dfa hash indicates if that is
+            # the case
+            #
+            # Start with the final result if nothing matches, and back up the
+            # stack until we find a dfa that would lead to a different result.
             my $final = pop @values;
+            while (   @values > 1
+                   && ! $dfas_ref->{$values[-2]}{dont_optimize_out})
+            {
+                my $match = $dfas_ref->{$values[-2]}{match_return};
+                $match = $dfas_ref->{$match}{match_return} if $match =~ /\D/;
+                last if $match != $final->{value};
+                pop @values; pop @values;
+            }
+
+            # If the stack gets completely emptied, replace the cell with the
+            # unconditional result.
+            if (@values == 0) {
+                $table_ref->[$x][$y] = $final;
+                next;
+            }
 
-            # The value that goes into the cell will be an index
+            # Otherwise the value that goes into the cell will be an index
             # into the dfa table, calculated later.  For now, we save the rule
             # number of the highest priority dfa, found in [0].
             undef $table_ref->[$x][$y];
@@ -2421,6 +2444,7 @@ sub output_LB_table() {
         LB_CM_ZWJ_v_any                 => {
                                              enum => 3,
                                              match_return => 'LB_NOBREAK',
+                                             dont_optimize_out => 1,
                                              rule => 9,
                                            },
         LB_OP_then_SP_v_any             => {