Skip to content

Commit

Permalink
builtin::trim: remove never executed code
Browse files Browse the repository at this point in the history
builtin::trim is always XS, never an OP, so the TARGLEX optimization
doesn't apply.
  • Loading branch information
tonycoz committed Nov 26, 2024
1 parent 9c2a10f commit d700717
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,27 +275,21 @@ XS(XS_builtin_trim)

dest = TARG;

if (SvPOK(dest) && (dest == source)) {
sv_chop(dest, (const char *)start);
SvCUR_set(dest, len);
}
else {
SvUPGRADE(dest, SVt_PV);
SvGROW(dest, len + 1);
SvUPGRADE(dest, SVt_PV);
SvGROW(dest, len + 1);

Copy(start, SvPVX(dest), len, U8);
SvPVX(dest)[len] = '\0';
SvPOK_only_UTF8(dest);
SvCUR_set(dest, len);
Copy(start, SvPVX(dest), len, U8);
SvPVX(dest)[len] = '\0';
SvPOK_only_UTF8(dest);
SvCUR_set(dest, len);

if (DO_UTF8(source))
SvUTF8_on(dest);
else
SvUTF8_off(dest);
if (DO_UTF8(source))
SvUTF8_on(dest);
else
SvUTF8_off(dest);

if (SvTAINTED(source))
SvTAINT(dest);
}
if (SvTAINTED(source))
SvTAINT(dest);

SvSETMAGIC(dest);

Expand Down

0 comments on commit d700717

Please sign in to comment.