diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-09-05 09:30:34 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-09-13 21:14:03 -0600 |
commit | 30188af71480bee44fe725708944a74f91763cf2 (patch) | |
tree | 8c0fa631d3b2b2fe28d452954244c39d2589de92 /regen | |
parent | 2efb81438aa4370f4aeabca6e03ab28f3bd552fb (diff) | |
download | perl-30188af71480bee44fe725708944a74f91763cf2.tar.gz |
regen/regcharclass.pl: Rmv always true components from gen'd macro
This adds a test and returns 1 from a subroutine if the condition will
always match; and in the caller it adds a check for that, and omits the
condition from the generated macro.
Diffstat (limited to 'regen')
-rwxr-xr-x | regen/regcharclass.pl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/regen/regcharclass.pl b/regen/regcharclass.pl index 826798ce26..29e224c7de 100755 --- a/regen/regcharclass.pl +++ b/regen/regcharclass.pl @@ -670,6 +670,7 @@ sub _cond_as_str { # for it. This doesn't apply if returning the code point, as we want each # element of the set individually. if (! $is_cp_ret) { + return 1 if @$cond == 256; my ($mask, $base) = calculate_mask(@$cond); if (defined $mask && defined $base) { return sprintf "( ( $test & $self->{val_fmt} ) == $self->{val_fmt} )", $mask, $base; @@ -746,6 +747,8 @@ sub _render { #no warnings 'recursion'; # This would allow really really inefficient # code to be generated. See pod my $yes= $self->_render( $op->{yes}, $combine, 1, $opts_ref ); + return $yes if $cond eq '1'; + my $no= $self->_render( $op->{no}, $combine, 0, $opts_ref ); return "( $cond )" if $yes eq '1' and $no eq '0'; my ( $lb, $rb )= $brace ? ( "( ", " )" ) : ( "", "" ); |