From: Nicholas Clark Date: Mon, 7 Nov 2005 21:31:16 +0000 (+0000) Subject: Merge pp_slt, pp_sgt and pp_sge into pp_sle. (The most commonly used X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=afd9910b0da24dd1fe1207d445456a8c0f2176c5;p=p5sagit%2Fp5-mst-13.2.git Merge pp_slt, pp_sgt and pp_sge into pp_sle. (The most commonly used of the 4. Not that any are that popular.) p4raw-id: //depot/perl@26039 --- diff --git a/mathoms.c b/mathoms.c index c0fc740..113aac0 100644 --- a/mathoms.c +++ b/mathoms.c @@ -1020,6 +1020,21 @@ PP(pp_lcfirst) return pp_ucfirst(); } +PP(pp_slt) +{ + return pp_sle(); +} + +PP(pp_sgt) +{ + return pp_sle(); +} + +PP(pp_sge) +{ + return pp_sle(); +} + U8 * Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv) { diff --git a/opcode.h b/opcode.h index 0086001..7cd088e 100644 --- a/opcode.h +++ b/opcode.h @@ -850,10 +850,10 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */ MEMBER_TO_FPTR(Perl_pp_i_ne), MEMBER_TO_FPTR(Perl_pp_ncmp), MEMBER_TO_FPTR(Perl_pp_i_ncmp), - MEMBER_TO_FPTR(Perl_pp_slt), - MEMBER_TO_FPTR(Perl_pp_sgt), + MEMBER_TO_FPTR(Perl_pp_sle), /* Perl_pp_slt */ + MEMBER_TO_FPTR(Perl_pp_sle), /* Perl_pp_sgt */ MEMBER_TO_FPTR(Perl_pp_sle), - MEMBER_TO_FPTR(Perl_pp_sge), + MEMBER_TO_FPTR(Perl_pp_sle), /* Perl_pp_sge */ MEMBER_TO_FPTR(Perl_pp_seq), MEMBER_TO_FPTR(Perl_pp_sne), MEMBER_TO_FPTR(Perl_pp_scmp), diff --git a/opcode.pl b/opcode.pl index 0c1026d..ae7ee66 100755 --- a/opcode.pl +++ b/opcode.pl @@ -77,6 +77,7 @@ my @raw_alias = ( Perl_pp_and => ['andassign'], Perl_pp_or => ['orassign'], Perl_pp_ucfirst => ['lcfirst'], + Perl_pp_sle => [qw(slt sgt sge)], ); while (my ($func, $names) = splice @raw_alias, 0, 2) { diff --git a/pp.c b/pp.c index 8d34510..401e1e3 100644 --- a/pp.c +++ b/pp.c @@ -2091,54 +2091,40 @@ PP(pp_ncmp) } } -PP(pp_slt) +PP(pp_sle) { - dSP; tryAMAGICbinSET_var(slt_amg,0); - { - dPOPTOPssrl; - const int cmp = (IN_LOCALE_RUNTIME - ? sv_cmp_locale(left, right) - : sv_cmp(left, right)); - SETs(boolSV(cmp < 0)); - RETURN; - } -} + dSP; -PP(pp_sgt) -{ - dSP; tryAMAGICbinSET_var(sgt_amg,0); - { - dPOPTOPssrl; - const int cmp = (IN_LOCALE_RUNTIME - ? sv_cmp_locale(left, right) - : sv_cmp(left, right)); - SETs(boolSV(cmp > 0)); - RETURN; - } -} + int amg_type = sle_amg; + int multiplier = 1; + int rhs = 1; -PP(pp_sle) -{ - dSP; tryAMAGICbinSET_var(sle_amg,0); - { - dPOPTOPssrl; - const int cmp = (IN_LOCALE_RUNTIME - ? sv_cmp_locale(left, right) - : sv_cmp(left, right)); - SETs(boolSV(cmp <= 0)); - RETURN; + switch (PL_op->op_type) { + case OP_SLT: + amg_type = slt_amg; + /* cmp < 0 */ + rhs = 0; + break; + case OP_SGT: + amg_type = sgt_amg; + /* cmp > 0 */ + multiplier = -1; + rhs = 0; + break; + case OP_SGE: + amg_type = sge_amg; + /* cmp >= 0 */ + multiplier = -1; + break; } -} -PP(pp_sge) -{ - dSP; tryAMAGICbinSET_var(sge_amg,0); + tryAMAGICbinSET_var(amg_type,0); { dPOPTOPssrl; const int cmp = (IN_LOCALE_RUNTIME ? sv_cmp_locale(left, right) : sv_cmp(left, right)); - SETs(boolSV(cmp >= 0)); + SETs(boolSV(cmp * multiplier < rhs)); RETURN; } }