From: Nicholas Clark Date: Fri, 23 Oct 2009 14:44:16 +0000 (+0100) Subject: S_utf16_textfilter() can use the filter GV itself for an SV buffer. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f3040f2ca0eac516f4e8401bd98f55bfdf329a5d;p=p5sagit%2Fp5-mst-13.2.git S_utf16_textfilter() can use the filter GV itself for an SV buffer. This saves allocating an extra SV head and body. --- diff --git a/toke.c b/toke.c index d83ac6a..e1f98dc 100644 --- a/toke.c +++ b/toke.c @@ -12776,11 +12776,11 @@ static I32 S_utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen) { dVAR; + SV *const filter = FILTER_DATA(idx); /* We re-use this each time round, throwing the contents away before we return. */ - SV *const filter = FILTER_DATA(idx); SV *const utf16_buffer = MUTABLE_SV(IoTOP_GV(filter)); - SV *const utf8_buffer = MUTABLE_SV(IoFMT_GV(filter)); + SV *const utf8_buffer = filter; IV status = IoPAGE(filter); const bool reverse = IoLINES(filter); @@ -12895,7 +12895,7 @@ S_add_utf16_textfilter(pTHX_ U8 *const s, bool reversed) SV *filter = filter_add(S_utf16_textfilter, NULL); IoTOP_GV(filter) = MUTABLE_GV(newSVpvn((char *)s, PL_bufend - (char*)s)); - IoFMT_GV(filter) = MUTABLE_GV(newSVpvs("")); + sv_setpvs(filter, ""); IoLINES(filter) = reversed; IoPAGE(filter) = 1; /* Not EOF */