In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/4464f08ea532be08ea7f0c44d0eb6e285a0c36fb?hp=d74adc6a1d9383142243c7a8afde44878b9452f1>

- Log -----------------------------------------------------------------
commit 4464f08ea532be08ea7f0c44d0eb6e285a0c36fb
Author: Nicholas Clark <[email protected]>
Date:   Fri Oct 23 16:54:10 2009 +0100

    S_run_user_filter() can use the filter GV itself for the cache buffer.
    
    This saves allocating an extra SV head and body.

M       pp_ctl.c

commit f3040f2ca0eac516f4e8401bd98f55bfdf329a5d
Author: Nicholas Clark <[email protected]>
Date:   Fri Oct 23 15:44:16 2009 +0100

    S_utf16_textfilter() can use the filter GV itself for an SV buffer.
    
    This saves allocating an extra SV head and body.

M       toke.c
-----------------------------------------------------------------------

Summary of changes:
 pp_ctl.c |   18 +++++++++---------
 toke.c   |    6 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/pp_ctl.c b/pp_ctl.c
index ea066a0..7d7ad1f 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3573,11 +3573,14 @@ PP(pp_require)
         PL_compiling.cop_warnings = pWARN_STD ;
 
     if (filter_sub || filter_cache) {
-       SV * const datasv = filter_add(S_run_user_filter, NULL);
+       /* We can use the SvPV of the filter PVIO itself as our cache, rather
+          than hanging another SV from it. In turn, filter_add() optionally
+          takes the SV to use as the filter (or creates a new SV if passed
+          NULL), so simply pass in whatever value filter_cache has.  */
+       SV * const datasv = filter_add(S_run_user_filter, filter_cache);
        IoLINES(datasv) = filter_has_file;
        IoTOP_GV(datasv) = MUTABLE_GV(filter_state);
        IoBOTTOM_GV(datasv) = MUTABLE_GV(filter_sub);
-       IoFMT_GV(datasv) = MUTABLE_GV(filter_cache);
     }
 
     /* switch to eval mode */
@@ -4830,8 +4833,8 @@ S_run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen)
        for PL_parser->error_count == 0.)  Solaris doesn't segfault --
        not sure where the trouble is yet.  XXX */
 
-    if (IoFMT_GV(datasv)) {
-       SV *const cache = MUTABLE_SV(IoFMT_GV(datasv));
+    {
+       SV *const cache = datasv;
        if (SvOK(cache)) {
            STRLEN cache_len;
            const char *cache_p = SvPV(cache, cache_len);
@@ -4930,11 +4933,9 @@ S_run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen)
     if (prune_from) {
        /* Oh. Too long. Stuff some in our cache.  */
        STRLEN cached_len = got_p + got_len - prune_from;
-       SV *cache = MUTABLE_SV(IoFMT_GV(datasv));
+       SV *const cache = datasv;
 
-       if (!cache) {
-           IoFMT_GV(datasv) = MUTABLE_GV((cache = newSV(got_len - umaxlen)));
-       } else if (SvOK(cache)) {
+       if (SvOK(cache)) {
            /* Cache should be empty.  */
            assert(!SvCUR(cache));
        }
@@ -4963,7 +4964,6 @@ S_run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen)
 
     if (status <= 0) {
        IoLINES(datasv) = 0;
-       SvREFCNT_dec(IoFMT_GV(datasv));
        if (filter_state) {
            SvREFCNT_dec(filter_state);
            IoTOP_GV(datasv) = NULL;
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 */
 

--
Perl5 Master Repository

Reply via email to