summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-07-15 21:24:02 +0100
committerDavid Mitchell <davem@iabyn.com>2013-07-28 10:33:38 +0100
commit2ec7214c34f5d160ff6a0e8acb3f151c5974e83a (patch)
tree633d44c5a164f07ddfa55b689bb97a6e2cafc877 /pp_hot.c
parentc947cd8d4017ec6273b59c3f119e59654b960f34 (diff)
downloadperl-2ec7214c34f5d160ff6a0e8acb3f151c5974e83a.tar.gz
pp_subst: combine 3 small elsif blocks into 1
and slightly reduce the scope of the temporary i var.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/pp_hot.c b/pp_hot.c
index e59c9fe58f..27ecb4a4ee 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2179,13 +2179,13 @@ PP(pp_subst)
if (once) {
char *d, *m;
- I32 i;
if (RX_MATCH_TAINTED(rx)) /* run time pattern taint, eg locale */
rxtainted |= SUBST_TAINT_PAT;
m = orig + RX_OFFS(rx)[0].start;
d = orig + RX_OFFS(rx)[0].end;
s = orig;
if (m - s > strend - d) { /* faster to shorten from end */
+ I32 i;
if (clen) {
Copy(c, m, clen, char);
m += clen;
@@ -2198,21 +2198,15 @@ PP(pp_subst)
*m = '\0';
SvCUR_set(TARG, m - s);
}
- else if ((i = m - s)) { /* faster from front */
+ else { /* faster from front */
+ I32 i = m - s;
d -= clen;
- Move(s, d - i, i, char);
+ if (i > 0)
+ Move(s, d - i, i, char);
sv_chop(TARG, d-i);
if (clen)
Copy(c, d, clen, char);
}
- else if (clen) {
- d -= clen;
- sv_chop(TARG, d);
- Copy(c, d, clen, char);
- }
- else {
- sv_chop(TARG, d);
- }
SPAGAIN;
PUSHs(&PL_sv_yes);
}