summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-06-30 11:41:24 -0600
committerKarl Williamson <khw@cpan.org>2021-08-07 04:46:45 -0600
commite542587307d1cb4f8a322d4a5bd5cbbe226f3c64 (patch)
tree781a42766a5f6324b5eab57057340f7854be02b0 /regen
parent933716a479d92e1c492a5e6f425c76c621c06f8b (diff)
downloadperl-e542587307d1cb4f8a322d4a5bd5cbbe226f3c64.tar.gz
regcharclass.pl: Reorder execution path
This moves a loop earlier in the execution path. This will be useful in a later commit
Diffstat (limited to 'regen')
-rwxr-xr-xregen/regcharclass.pl33
1 files changed, 16 insertions, 17 deletions
diff --git a/regen/regcharclass.pl b/regen/regcharclass.pl
index ae587d9952..5b467c4f63 100755
--- a/regen/regcharclass.pl
+++ b/regen/regcharclass.pl
@@ -1140,6 +1140,22 @@ sub _cond_as_str {
$loop_end--;
}
+ # Look at each range to see if there any optimizations.
+ for (my $i = $loop_start; $i < $loop_end; $i++) {
+ if (! ref $ranges[$i]) { # Trivial case: no range
+ $ranges[$i] = $self->val_fmt($ranges[$i]) . " == $test";
+ }
+ elsif ($ranges[$i]->[0] == $ranges[$i]->[1]) {
+ $ranges[$i] = # Trivial case: single element range
+ $self->val_fmt($ranges[$i]->[0]) . " == $test";
+ }
+ else {
+ $ranges[$i] = "inRANGE_helper_(U8, $test, "
+ . $self->val_fmt($ranges[$i]->[0]) .", "
+ . $self->val_fmt($ranges[$i]->[1]) . ")";
+ }
+ }
+
my @masks;
if (@ranges > 1) {
@@ -1175,23 +1191,6 @@ sub _cond_as_str {
}
}
- # Here, there was no entire-class optimization that was clearly better
- # than doing things by ranges. Look at each range.
- for (my $i = $loop_start; $i < $loop_end; $i++) {
- if (! ref $ranges[$i]) { # Trivial case: no range
- $ranges[$i] = $self->val_fmt($ranges[$i]) . " == $test";
- }
- elsif ($ranges[$i]->[0] == $ranges[$i]->[1]) {
- $ranges[$i] = # Trivial case: single element range
- $self->val_fmt($ranges[$i]->[0]) . " == $test";
- }
- else {
- $ranges[$i] = "inRANGE_helper_(U8, $test, "
- . $self->val_fmt($ranges[$i]->[0]) .", "
- . $self->val_fmt($ranges[$i]->[1]) . ")";
- }
- }
-
# We have generated the list of bytes in two ways; one trying to use masks
# to cut the number of branches down, and the other to look at individual
# ranges (some of which could be cut down by using a mask for just it).