summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-01-01 20:26:27 +0000
committerNicholas Clark <nick@ccl4.org>2005-01-01 20:26:27 +0000
commit770526c17acd97e1e85c98bfca98d1d4b69f53f8 (patch)
treecf9680519f3303b2264ba3ac94c1cd7b69c68706
parent9431620da4dbda8a9753e557013462a4cc50b03f (diff)
downloadperl-770526c17acd97e1e85c98bfca98d1d4b69f53f8.tar.gz
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
-rw-r--r--doio.c8
-rw-r--r--locale.c8
-rw-r--r--op.c18
-rw-r--r--perl.c4
-rw-r--r--pp.c4
-rw-r--r--toke.c22
-rw-r--r--util.c4
7 files changed, 39 insertions, 29 deletions
diff --git a/doio.c b/doio.c
index 5e568ed50b..12ec5fef97 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 a73c5d68d2..c6b8782084 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 8fce725bdd..2b69595144 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 7cd8e3b0c4..54783bbd42 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 03de7e4fa6..0fa7e2413a 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 d79c1230ba..ea3714e310 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 5a8ae3be82..e99c6af68d 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];