This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge PL_scream{first,next} into one allocated buffer.
authorNicholas Clark <nick@ccl4.org>
Mon, 27 Jun 2011 15:58:10 +0000 (17:58 +0200)
committerNicholas Clark <nick@ccl4.org>
Fri, 1 Jul 2011 12:05:40 +0000 (14:05 +0200)
Effectively, PL_screamnext is now PL_screamfirst + 256. The actual interpreter
variable PL_screamnext is eliminated.

embedvar.h
intrpvar.h
perl.c
pp.c
sv.c
util.c

index a540fd6..c25fb57 100644 (file)
 #define PL_scopestack_max      (vTHX->Iscopestack_max)
 #define PL_scopestack_name     (vTHX->Iscopestack_name)
 #define PL_screamfirst         (vTHX->Iscreamfirst)
-#define PL_screamnext          (vTHX->Iscreamnext)
 #define PL_secondgv            (vTHX->Isecondgv)
 #define PL_sharehook           (vTHX->Isharehook)
 #define PL_sig_pending         (vTHX->Isig_pending)
 #define PL_Iscopestack_max     PL_scopestack_max
 #define PL_Iscopestack_name    PL_scopestack_name
 #define PL_Iscreamfirst                PL_screamfirst
-#define PL_Iscreamnext         PL_screamnext
 #define PL_Isecondgv           PL_secondgv
 #define PL_Isharehook          PL_sharehook
 #define PL_Isig_pending                PL_sig_pending
index 9dda6a3..3a64cb2 100644 (file)
@@ -156,7 +156,6 @@ PERLVAR(Iefloatsize,        STRLEN)
 /* regex stuff */
 
 PERLVAR(Iscreamfirst,  I32 *)
-PERLVAR(Iscreamnext,   I32 *)
 PERLVAR(Ilastscream,   SV *)
 
 PERLVAR(Ireg_state,    struct re_save_state)
diff --git a/perl.c b/perl.c
index 417b2fd..00aa028 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -910,8 +910,6 @@ perl_destruct(pTHXx)
     PL_lastscream = NULL;
     Safefree(PL_screamfirst);
     PL_screamfirst = 0;
-    Safefree(PL_screamnext);
-    PL_screamnext  = 0;
 
     /* float buffer */
     Safefree(PL_efloatbuf);
diff --git a/pp.c b/pp.c
index 61e9dc1..992eaff 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -740,24 +740,21 @@ PP(pp_study)
     if (pos > PL_maxscream) {
        if (PL_maxscream < 0) {
            PL_maxscream = pos + 80;
-           Newx(PL_screamfirst, 256, I32);
-           Newx(PL_screamnext, PL_maxscream, I32);
+           Newx(PL_screamfirst, 256 + PL_maxscream, I32);
        }
        else {
            PL_maxscream = pos + pos / 4;
-           Renew(PL_screamnext, PL_maxscream, I32);
+           Renew(PL_screamfirst, 256 + PL_maxscream, I32);
        }
     }
 
-    sfirst = PL_screamfirst;
-    snext = PL_screamnext;
+    snext = sfirst = PL_screamfirst;
 
-    if (!sfirst || !snext)
+    if (!sfirst)
        DIE(aTHX_ "do_study: out of memory");
 
     for (ch = 256; ch; --ch)
-       *sfirst++ = -1;
-    sfirst -= 256;
+       *snext++ = -1;
 
     while (--pos >= 0) {
        register const I32 ch = s[pos];
diff --git a/sv.c b/sv.c
index 445f9d4..75238bc 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12995,7 +12995,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     /* regex stuff */
 
     PL_screamfirst     = NULL;
-    PL_screamnext      = NULL;
     PL_maxscream       = -1;                   /* reinits on demand */
     PL_lastscream      = NULL;
 
diff --git a/util.c b/util.c
index 9185e08..e099fda 100644 (file)
--- a/util.c
+++ b/util.c
@@ -861,6 +861,7 @@ Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift
     register I32 stop_pos;
     register const unsigned char *littleend;
     I32 found = 0;
+    const I32 *screamnext = PL_screamfirst + 256;
 
     PERL_ARGS_ASSERT_SCREAMINSTR;
 
@@ -868,7 +869,7 @@ Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift
     assert(SvVALID(littlestr));
 
     pos = *old_posp == -1
-       ? PL_screamfirst[BmRARE(littlestr)] : PL_screamnext[*old_posp];
+       ? PL_screamfirst[BmRARE(littlestr)] : screamnext[*old_posp];
     if (pos == -1) {
       cant_find:
        if ( BmRARE(littlestr) == '\n'
@@ -901,7 +902,7 @@ Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift
        return NULL;
     }
     while (pos < previous + start_shift) {
-       pos = PL_screamnext[pos];
+       pos = screamnext[pos];
        if (pos == -1)
            goto cant_find;
     }
@@ -922,7 +923,7 @@ Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift
                found = 1;
            }
        }
-       pos = PL_screamnext[pos];
+       pos = screamnext[pos];
     } while (pos != -1);
     if (last && found)
        return (char *)(big+(*old_posp));