From: Nicholas Clark Date: Sat, 1 Jan 2005 20:26:27 +0000 (+0000) Subject: strEQ/strNE of 1 character strings seems better hand inlined, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=770526c17acd97e1e85c98bfca98d1d4b69f53f8;p=p5sagit%2Fp5-mst-13.2.git strEQ/strNE of 1 character strings seems better hand inlined, because it generates smaller object code (as well as being faster than a true function call) p4raw-id: //depot/perl@23725 --- diff --git a/doio.c b/doio.c index 5e568ed..12ec5fe 100644 --- a/doio.c +++ b/doio.c @@ -1,7 +1,7 @@ /* doio.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others + * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -265,7 +265,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, errno = EPIPE; goto say_false; } - if (strNE(name,"-") || num_svs) + if ((*name == '-' && name[1] == '\0') || num_svs) TAINT_ENV(); TAINT_PROPER("piped open"); if (!num_svs && name[len-1] == '|') { @@ -483,7 +483,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, errno = EPIPE; goto say_false; } - if (strNE(name,"-") || num_svs) + if (!(*name == '-' && name[1] == '\0') || num_svs) TAINT_ENV(); TAINT_PROPER("piped open"); mode[0] = 'r'; @@ -519,7 +519,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, strcat(mode, "b"); else if (in_crlf) strcat(mode, "t"); - if (strEQ(name,"-")) { + if (*name == '-' && name[1] == '\0') { fp = PerlIO_stdin(); IoTYPE(io) = IoTYPE_STD; } diff --git a/locale.c b/locale.c index a73c5d6..c6b8782 100644 --- a/locale.c +++ b/locale.c @@ -1,7 +1,7 @@ /* locale.c * * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, by Larry Wall and others + * 2000, 2001, 2002, 2003, 2005, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -127,7 +127,8 @@ Perl_new_numeric(pTHX_ char *newnum) if (! PL_numeric_name || strNE(PL_numeric_name, newnum)) { Safefree(PL_numeric_name); PL_numeric_name = stdize_locale(savepv(newnum)); - PL_numeric_standard = (strEQ(newnum, "C") || strEQ(newnum, "POSIX")); + PL_numeric_standard = ((*newnum == 'C' && newnum[1] == '\0') + || strEQ(newnum, "POSIX")); PL_numeric_local = TRUE; set_numeric_radix(); } @@ -211,7 +212,8 @@ Perl_new_collate(pTHX_ char *newcoll) ++PL_collation_ix; Safefree(PL_collation_name); PL_collation_name = stdize_locale(savepv(newcoll)); - PL_collation_standard = (strEQ(newcoll, "C") || strEQ(newcoll, "POSIX")); + PL_collation_standard = ((*newcoll == 'C' && newcoll[1] == '\0') + || strEQ(newcoll, "POSIX")); { /* 2: at most so many chars ('a', 'b'). */ diff --git a/op.c b/op.c index 8fce725..2b69595 100644 --- a/op.c +++ b/op.c @@ -2763,7 +2763,7 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg) STRLEN plen; SV *pat = ((SVOP*)expr)->op_sv; char *p = SvPV(pat, plen); - if ((o->op_flags & OPf_SPECIAL) && strEQ(p, " ")) { + if ((o->op_flags & OPf_SPECIAL) && (*p == ' ' && p[1] == '\0')) { sv_setpvn(pat, "\\s+", 3); p = SvPV(pat, plen); pm->op_pmflags |= PMf_SKIPWHITE; @@ -6029,6 +6029,7 @@ S_simplify_sort(pTHX_ OP *o) OP *k; int descending; GV *gv; + const char *gvname; if (!(o->op_flags & OPf_STACKED)) return; GvMULTI_on(gv_fetchpv("a", TRUE, SVt_PV)); @@ -6055,9 +6056,10 @@ S_simplify_sort(pTHX_ OP *o) gv = kGVOP_gv; if (GvSTASH(gv) != PL_curstash) return; - if (strEQ(GvNAME(gv), "a")) + gvname = GvNAME(gv); + if (*gvname == 'a' && gvname[1] == '\0') descending = 0; - else if (strEQ(GvNAME(gv), "b")) + else if (*gvname == 'b' && gvname[1] == '\0') descending = 1; else return; @@ -6070,10 +6072,12 @@ S_simplify_sort(pTHX_ OP *o) return; kid = kUNOP->op_first; /* get past rv2sv */ gv = kGVOP_gv; - if (GvSTASH(gv) != PL_curstash - || ( descending - ? strNE(GvNAME(gv), "a") - : strNE(GvNAME(gv), "b"))) + if (GvSTASH(gv) != PL_curstash) + return; + gvname = GvNAME(gv); + if ( descending + ? !(*gvname == 'a' && gvname[1] == '\0') + : !(*gvname == 'b' && gvname[1] == '\0')) return; o->op_flags &= ~(OPf_STACKED | OPf_SPECIAL); if (descending) diff --git a/perl.c b/perl.c index 7cd8e3b..54783bb 100644 --- a/perl.c +++ b/perl.c @@ -1,7 +1,7 @@ /* perl.c * * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others + * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -3089,7 +3089,7 @@ S_open_script(pTHX_ char *scriptname, bool dosearch, SV *sv) CopFILE_free(PL_curcop); CopFILE_set(PL_curcop, PL_origfilename); - if (strEQ(PL_origfilename,"-")) + if (*PL_origfilename == '-' && PL_origfilename[1] == '\0') scriptname = ""; if (PL_fdscript >= 0) { PL_rsfp = PerlIO_fdopen(PL_fdscript,PERL_SCRIPT_MODE); diff --git a/pp.c b/pp.c index 03de7e4..0fa7e24 100644 --- a/pp.c +++ b/pp.c @@ -1,7 +1,7 @@ /* pp.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others + * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -4550,7 +4550,7 @@ PP(pp_split) ++s; } } - else if (strEQ("^", rx->precomp)) { + else if (rx->precomp[0] == '^' && rx->precomp[1] == '\0') { while (--limit) { /*SUPPRESS 530*/ for (m = s; m < strend && *m != '\n'; m++) ; diff --git a/toke.c b/toke.c index d79c123..ea3714e 100644 --- a/toke.c +++ b/toke.c @@ -1,7 +1,7 @@ /* toke.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others + * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -4253,7 +4253,7 @@ Perl_yylex(pTHX) char *proto = SvPV((SV*)cv, len); if (!len) TERM(FUNC0SUB); - if (strEQ(proto, "$")) + if (*proto == '$' && proto[1] == '\0') OPERATOR(UNIOPSUB); while (*proto == ';') proto++; @@ -5788,7 +5788,7 @@ Perl_keyword(pTHX_ register char *d, I32 len) else if (*d == 'l') { if (strEQ(d,"login")) return -KEY_getlogin; } - else if (strEQ(d,"c")) return -KEY_getc; + else if (*d == 'c' && d[1] == '\0') return -KEY_getc; break; } switch (len) { @@ -5935,12 +5935,16 @@ Perl_keyword(pTHX_ register char *d, I32 len) } break; case 'q': - if (len <= 2) { - if (strEQ(d,"q")) return KEY_q; - if (strEQ(d,"qr")) return KEY_qr; - if (strEQ(d,"qq")) return KEY_qq; - if (strEQ(d,"qw")) return KEY_qw; - if (strEQ(d,"qx")) return KEY_qx; + if (len == 1) { + return KEY_q; + } + else if (len == 2) { + switch (d[1]) { + case 'r': return KEY_qr; + case 'q': return KEY_qq; + case 'w': return KEY_qw; + case 'x': return KEY_qx; + }; } else if (strEQ(d,"quotemeta")) return -KEY_quotemeta; break; diff --git a/util.c b/util.c index 5a8ae3b..e99c6af 100644 --- a/util.c +++ b/util.c @@ -1,7 +1,7 @@ /* util.c * * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others + * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -2045,7 +2045,7 @@ Perl_my_popen(pTHX_ char *cmd, char *mode) register I32 This, that; register Pid_t pid; SV *sv; - I32 doexec = strNE(cmd,"-"); + I32 doexec = !(*cmd == '-' && cmd[1] == '\0'); I32 did_pipes = 0; int pp[2];