From 151cea252da4316fddd84956c61bbb23ecff1bb5 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 19 Nov 2011 00:30:14 -0800 Subject: [PATCH] Avoid a redundant copy in pp_glob MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Most of the time, the argument to glob() won’t be tied, so we don’t need to copy it. So only copy it if it is gmagical. --- pp_sys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pp_sys.c b/pp_sys.c index 3458177..958a133 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -355,9 +355,9 @@ PP(pp_glob) dVAR; OP *result; dSP; - /* make a copy of the pattern, to ensure that magic is called once - * and only once */ - TOPm1s = sv_2mortal(newSVsv(TOPm1s)); + /* make a copy of the pattern if it is gmagical, to ensure that magic + * is called once and only once */ + if (SvGMAGICAL(TOPm1s)) TOPm1s = sv_2mortal(newSVsv(TOPm1s)); tryAMAGICunTARGET(iter_amg, -1, (PL_op->op_flags & OPf_SPECIAL)); -- 1.8.3.1