Use sv_catpvs where appropriate vs sv_catpv

This moves calculations definitely to compile time; some optimizing
compilers may already do this, but some may not.
This commit is contained in:
Karl Williamson 2018-08-05 06:41:05 -06:00
parent 00d976bbd1
commit f8db7d5b69
7 changed files with 70 additions and 70 deletions

10
doio.c
View File

@ -3244,24 +3244,24 @@ Perl_vms_start_glob
# if defined(OS2)
sv_setpv(tmpcmd, "for a in ");
sv_catsv(tmpcmd, tmpglob);
sv_catpv(tmpcmd, "; do echo \"$a\\0\\c\"; done |");
sv_catpvs(tmpcmd, "; do echo \"$a\\0\\c\"; done |");
# elif defined(DJGPP)
sv_setpv(tmpcmd, "/dev/dosglob/"); /* File System Extension */
sv_catsv(tmpcmd, tmpglob);
# else
sv_setpv(tmpcmd, "perlglob ");
sv_catsv(tmpcmd, tmpglob);
sv_catpv(tmpcmd, " |");
sv_catpvs(tmpcmd, " |");
# endif
# elif defined(CSH)
sv_setpvn(tmpcmd, PL_cshname, PL_cshlen);
sv_catpv(tmpcmd, " -cf 'set nonomatch; glob ");
sv_catpvs(tmpcmd, " -cf 'set nonomatch; glob ");
sv_catsv(tmpcmd, tmpglob);
sv_catpv(tmpcmd, "' 2>/dev/null |");
sv_catpvs(tmpcmd, "' 2>/dev/null |");
# else
sv_setpv(tmpcmd, "echo ");
sv_catsv(tmpcmd, tmpglob);
sv_catpv(tmpcmd, "|tr -s ' \t\f\r' '\\n\\n\\n\\n'|");
sv_catpvs(tmpcmd, "|tr -s ' \t\f\r' '\\n\\n\\n\\n'|");
# endif /* !DOSISH && !CSH */
{
SV ** const svp = hv_fetchs(GvHVn(PL_envgv), "LS_COLORS", 0);

94
dump.c
View File

@ -361,26 +361,26 @@ Perl_sv_peek(pTHX_ SV *sv)
SvPVCLEAR(t);
retry:
if (!sv) {
sv_catpv(t, "VOID");
sv_catpvs(t, "VOID");
goto finish;
}
else if (sv == (const SV *)0x55555555 || ((char)SvTYPE(sv)) == 'U') {
/* detect data corruption under memory poisoning */
sv_catpv(t, "WILD");
sv_catpvs(t, "WILD");
goto finish;
}
else if ( sv == &PL_sv_undef || sv == &PL_sv_no || sv == &PL_sv_yes
|| sv == &PL_sv_zero || sv == &PL_sv_placeholder)
{
if (sv == &PL_sv_undef) {
sv_catpv(t, "SV_UNDEF");
sv_catpvs(t, "SV_UNDEF");
if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|
SVs_GMG|SVs_SMG|SVs_RMG)) &&
SvREADONLY(sv))
goto finish;
}
else if (sv == &PL_sv_no) {
sv_catpv(t, "SV_NO");
sv_catpvs(t, "SV_NO");
if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
SVs_GMG|SVs_SMG|SVs_RMG)) &&
!(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
@ -390,7 +390,7 @@ Perl_sv_peek(pTHX_ SV *sv)
goto finish;
}
else if (sv == &PL_sv_yes) {
sv_catpv(t, "SV_YES");
sv_catpvs(t, "SV_YES");
if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
SVs_GMG|SVs_SMG|SVs_RMG)) &&
!(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
@ -401,7 +401,7 @@ Perl_sv_peek(pTHX_ SV *sv)
goto finish;
}
else if (sv == &PL_sv_zero) {
sv_catpv(t, "SV_ZERO");
sv_catpvs(t, "SV_ZERO");
if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
SVs_GMG|SVs_SMG|SVs_RMG)) &&
!(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
@ -412,16 +412,16 @@ Perl_sv_peek(pTHX_ SV *sv)
goto finish;
}
else {
sv_catpv(t, "SV_PLACEHOLDER");
sv_catpvs(t, "SV_PLACEHOLDER");
if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|
SVs_GMG|SVs_SMG|SVs_RMG)) &&
SvREADONLY(sv))
goto finish;
}
sv_catpv(t, ":");
sv_catpvs(t, ":");
}
else if (SvREFCNT(sv) == 0) {
sv_catpv(t, "(");
sv_catpvs(t, "(");
unref++;
}
else if (DEBUG_R_TEST_) {
@ -445,11 +445,11 @@ Perl_sv_peek(pTHX_ SV *sv)
}
if (SvROK(sv)) {
sv_catpv(t, "\\");
sv_catpvs(t, "\\");
if (SvCUR(t) + unref > 10) {
SvCUR_set(t, unref + 3);
*SvEND(t) = '\0';
sv_catpv(t, "...");
sv_catpvs(t, "...");
goto finish;
}
sv = SvRV(sv);
@ -469,16 +469,16 @@ Perl_sv_peek(pTHX_ SV *sv)
if (type == SVt_NULL)
goto finish;
} else {
sv_catpv(t, "FREED");
sv_catpvs(t, "FREED");
goto finish;
}
if (SvPOKp(sv)) {
if (!SvPVX_const(sv))
sv_catpv(t, "(null)");
sv_catpvs(t, "(null)");
else {
SV * const tmp = newSVpvs("");
sv_catpv(t, "(");
sv_catpvs(t, "(");
if (SvOOK(sv)) {
STRLEN delta;
SvOOK_offset(sv, delta);
@ -505,13 +505,13 @@ Perl_sv_peek(pTHX_ SV *sv)
Perl_sv_catpvf(aTHX_ t, "(%" IVdf ")", (IV)SvIVX(sv));
}
else
sv_catpv(t, "()");
sv_catpvs(t, "()");
finish:
while (unref--)
sv_catpv(t, ")");
sv_catpvs(t, ")");
if (TAINTING_get && sv && SvTAINTED(sv))
sv_catpv(t, " [tainted]");
sv_catpvs(t, " [tainted]");
return SvPV_nolen(t);
}
@ -875,26 +875,26 @@ S_pm_description(pTHX_ const PMOP *pm)
PERL_ARGS_ASSERT_PM_DESCRIPTION;
if (pmflags & PMf_ONCE)
sv_catpv(desc, ",ONCE");
sv_catpvs(desc, ",ONCE");
#ifdef USE_ITHREADS
if (SvREADONLY(PL_regex_pad[pm->op_pmoffset]))
sv_catpv(desc, ":USED");
sv_catpvs(desc, ":USED");
#else
if (pmflags & PMf_USED)
sv_catpv(desc, ":USED");
sv_catpvs(desc, ":USED");
#endif
if (regex) {
if (RX_ISTAINTED(regex))
sv_catpv(desc, ",TAINTED");
sv_catpvs(desc, ",TAINTED");
if (RX_CHECK_SUBSTR(regex)) {
if (!(RX_INTFLAGS(regex) & PREGf_NOSCAN))
sv_catpv(desc, ",SCANFIRST");
sv_catpvs(desc, ",SCANFIRST");
if (RX_EXTFLAGS(regex) & RXf_CHECK_ALL)
sv_catpv(desc, ",ALL");
sv_catpvs(desc, ",ALL");
}
if (RX_EXTFLAGS(regex) & RXf_SKIPWHITE)
sv_catpv(desc, ",SKIPWHITE");
sv_catpvs(desc, ",SKIPWHITE");
}
append_flags(desc, pmflags, pmflags_flags_names);
@ -1013,16 +1013,16 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
SV * const tmpsv = newSVpvs("");
switch (o->op_flags & OPf_WANT) {
case OPf_WANT_VOID:
sv_catpv(tmpsv, ",VOID");
sv_catpvs(tmpsv, ",VOID");
break;
case OPf_WANT_SCALAR:
sv_catpv(tmpsv, ",SCALAR");
sv_catpvs(tmpsv, ",SCALAR");
break;
case OPf_WANT_LIST:
sv_catpv(tmpsv, ",LIST");
sv_catpvs(tmpsv, ",LIST");
break;
default:
sv_catpv(tmpsv, ",UNKNOWN");
sv_catpvs(tmpsv, ",UNKNOWN");
break;
}
append_flags(tmpsv, o->op_flags, op_flags_names);
@ -1086,10 +1086,10 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
/* don't display anonymous zero values */
continue;
sv_catpv(tmpsv, ",");
sv_catpvs(tmpsv, ",");
if (label != -1) {
sv_catpv(tmpsv, &PL_op_private_labels[label]);
sv_catpv(tmpsv, "=");
sv_catpvs(tmpsv, "=");
}
if (enum_label == -1)
Perl_sv_catpvf(aTHX_ tmpsv, "0x%" UVxf, (UV)val);
@ -1104,13 +1104,13 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
&& PL_op_private_labels[ix+1] == '\0'))
{
oppriv -= (1<<bit);
sv_catpv(tmpsv, ",");
sv_catpvs(tmpsv, ",");
sv_catpv(tmpsv, &PL_op_private_labels[ix]);
}
}
}
if (oppriv) {
sv_catpv(tmpsv, ",");
sv_catpvs(tmpsv, ",");
Perl_sv_catpvf(aTHX_ tmpsv, "0x%" UVxf, (UV)oppriv);
}
}
@ -1723,22 +1723,22 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
(int)(PL_dumpindent*level), "");
if ((flags & SVs_PADSTALE))
sv_catpv(d, "PADSTALE,");
sv_catpvs(d, "PADSTALE,");
if ((flags & SVs_PADTMP))
sv_catpv(d, "PADTMP,");
sv_catpvs(d, "PADTMP,");
append_flags(d, flags, first_sv_flags_names);
if (flags & SVf_ROK) {
sv_catpv(d, "ROK,");
if (SvWEAKREF(sv)) sv_catpv(d, "WEAKREF,");
sv_catpvs(d, "ROK,");
if (SvWEAKREF(sv)) sv_catpvs(d, "WEAKREF,");
}
if (flags & SVf_IsCOW && type != SVt_PVHV) sv_catpvs(d, "IsCOW,");
append_flags(d, flags, second_sv_flags_names);
if (flags & SVp_SCREAM && type != SVt_PVHV && !isGV_with_GP(sv)
&& type != SVt_PVAV) {
if (SvPCS_IMPORTED(sv))
sv_catpv(d, "PCS_IMPORTED,");
sv_catpvs(d, "PCS_IMPORTED,");
else
sv_catpv(d, "SCREAM,");
sv_catpvs(d, "SCREAM,");
}
/* process type-specific SV flags */
@ -1757,19 +1757,19 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
append_flags(d, GvFLAGS(sv), gp_flags_names);
}
if (isGV_with_GP(sv) && GvIMPORTED(sv)) {
sv_catpv(d, "IMPORT");
sv_catpvs(d, "IMPORT");
if (GvIMPORTED(sv) == GVf_IMPORTED)
sv_catpv(d, "ALL,");
sv_catpvs(d, "ALL,");
else {
sv_catpv(d, "(");
sv_catpvs(d, "(");
append_flags(d, GvFLAGS(sv), gp_flags_imported_names);
sv_catpv(d, " ),");
sv_catpvs(d, " ),");
}
}
/* FALLTHROUGH */
case SVt_PVMG:
default:
if (SvIsUV(sv) && !(flags & SVf_ROK)) sv_catpv(d, "IsUV,");
if (SvIsUV(sv) && !(flags & SVf_ROK)) sv_catpvs(d, "IsUV,");
break;
case SVt_PVAV:
@ -1777,13 +1777,13 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
}
/* SVphv_SHAREKEYS is also 0x20000000 */
if ((type != SVt_PVHV) && SvUTF8(sv))
sv_catpv(d, "UTF8");
sv_catpvs(d, "UTF8");
if (*(SvEND(d) - 1) == ',') {
SvCUR_set(d, SvCUR(d) - 1);
SvPVX(d)[SvCUR(d)] = '\0';
}
sv_catpv(d, ")");
sv_catpvs(d, ")");
s = SvPVX_const(d);
/* dump initial SV details */
@ -1938,8 +1938,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
Perl_dump_indent(aTHX_ level, file, " MAX = %" IVdf "\n",
(IV)AvMAX(sv));
SvPVCLEAR(d);
if (AvREAL(sv)) sv_catpv(d, ",REAL");
if (AvREIFY(sv)) sv_catpv(d, ",REIFY");
if (AvREAL(sv)) sv_catpvs(d, ",REAL");
if (AvREIFY(sv)) sv_catpvs(d, ",REIFY");
Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n",
SvCUR(d) ? SvPVX_const(d) + 1 : "");
if (nest < maxnest && AvARRAY(MUTABLE_AV(sv))) {

View File

@ -1151,7 +1151,7 @@ do_spawn_ve(pTHX_ SV *really, const char **argv, U32 flag, U32 execf, char *inic
documentation, DosQueryAppType sometimes (?)
does not append ".exe", so we could have
reached this place). */
sv_catpv(scrsv, ".exe");
sv_catpvs(scrsv, ".exe");
argv[0] = scr = SvPV(scrsv, n_a); /* Reload */
if (PerlLIO_stat(scr,&statbuf) >= 0
&& !S_ISDIR(statbuf.st_mode)) { /* Found */

View File

@ -4218,7 +4218,7 @@ S_require_file(pTHX_ SV *sv)
}
if (c == e && isIDFIRST_lazy_if_safe(name, e, utf8)) {
sv_catpv(msg, " (you may need to install the ");
sv_catpvs(msg, " (you may need to install the ");
for (c = name; c < e; c++) {
if (*c == '/') {
sv_catpvs(msg, "::");
@ -4227,14 +4227,14 @@ S_require_file(pTHX_ SV *sv)
sv_catpvn(msg, c, 1);
}
}
sv_catpv(msg, " module)");
sv_catpvs(msg, " module)");
}
}
else if (memENDs(name, len, ".h")) {
sv_catpv(msg, " (change .h to .ph maybe?) (did you run h2ph?)");
sv_catpvs(msg, " (change .h to .ph maybe?) (did you run h2ph?)");
}
else if (memENDs(name, len, ".ph")) {
sv_catpv(msg, " (did you run h2ph?)");
sv_catpvs(msg, " (did you run h2ph?)");
}
/* diag_listed_as: Can't locate %s */

View File

@ -12491,10 +12491,10 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
if (node_p) {
/* Convert to notation the rest of the code understands */
sv_catpv(substitute_parse, "\\x{");
sv_catpvs(substitute_parse, "\\x{");
sv_catpvn(substitute_parse, start_digit,
RExC_parse - start_digit);
sv_catpv(substitute_parse, "}");
sv_catpvs(substitute_parse, "}");
}
/* Move to after the dot (or ending brace the final time through.)
@ -12511,7 +12511,7 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
return FALSE;
}
sv_catpv(substitute_parse, ")");
sv_catpvs(substitute_parse, ")");
#ifdef EBCDIC
/* The values are Unicode, and therefore have to be converted to native
@ -17625,7 +17625,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
#if 0 /* Have decided not to deal with multi-char folds in inverted classes,
because too confusing */
if (invert) {
sv_catpv(substitute_parse, "(?:");
sv_catpvs(substitute_parse, "(?:");
}
#endif
@ -17645,7 +17645,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
&PL_sv_undef)
{
if (! first_time) {
sv_catpv(substitute_parse, "|");
sv_catpvs(substitute_parse, "|");
}
first_time = FALSE;
@ -17657,24 +17657,24 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
/* If the character class contains anything else besides these
* multi-character folds, have to include it in recursive parsing */
if (element_count) {
sv_catpv(substitute_parse, "|[");
sv_catpvs(substitute_parse, "|[");
prefix_end = SvCUR(substitute_parse);
sv_catpvn(substitute_parse, orig_parse, RExC_parse - orig_parse);
/* Put in a closing ']' only if not going off the end, as otherwise
* we are adding something that really isn't there */
if (RExC_parse < RExC_end) {
sv_catpv(substitute_parse, "]");
sv_catpvs(substitute_parse, "]");
}
}
sv_catpv(substitute_parse, ")");
sv_catpvs(substitute_parse, ")");
#if 0
if (invert) {
/* This is a way to get the parse to skip forward a whole named
* sequence instead of matching the 2nd character when it fails the
* first */
sv_catpv(substitute_parse, "(*THEN)(*SKIP)(*FAIL)|.)");
sv_catpvs(substitute_parse, "(*THEN)(*SKIP)(*FAIL)|.)");
}
#endif
@ -20022,11 +20022,11 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o, const regmatch_
U8 index = FLAGS(o) * 2;
if (index < C_ARRAY_LENGTH(anyofs)) {
if (*anyofs[index] != '[') {
sv_catpv(sv, "[");
sv_catpvs(sv, "[");
}
sv_catpv(sv, anyofs[index]);
if (*anyofs[index] != '[') {
sv_catpv(sv, "]");
sv_catpvs(sv, "]");
}
}
else {

2
toke.c
View File

@ -10331,7 +10331,7 @@ S_scan_heredoc(pTHX_ char *s)
while (ss < se) {
/* newline only? Copy and move on */
if (*ss == '\n') {
sv_catpv(newstr,"\n");
sv_catpvs(newstr,"\n");
ss++;
linecount++;

View File

@ -438,7 +438,7 @@ win32_get_xlib(const char *pl, WIN32_NO_REGISTRY_M_(const char *xlib)
sv1 = sv2;
} else if (sv2) {
dTHX;
sv_catpv(sv1, ";");
sv_catpvs(sv1, ";");
sv_catsv(sv1, sv2);
}