Turn on read-only flag for some unchangeable inversion lists
authorKarl Williamson <public@khwilliamson.com>
Thu, 16 Jan 2014 17:23:31 +0000 (10:23 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 16 Jan 2014 17:53:05 +0000 (10:53 -0700)
These lists are read-only.  Turning on the flag may allow some
optimisations to be done, including some that may be added in the
future.

regcomp.c
utf8.c

index d531053..decbe4a 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7686,6 +7686,8 @@ Perl__new_invlist_C_array(pTHX_ const UV* const list)
     /* Initialize the iteration pointer. */
     invlist_iterfinish(invlist);
 
+    SvREADONLY_on(invlist);
+
     return invlist;
 }
 #endif /* ifndef PERL_IN_XSUB_RE */
diff --git a/utf8.c b/utf8.c
index f4b9dc6..1b198bf 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -2735,6 +2735,8 @@ Perl__core_swash_init(pTHX_ const char* pkg, const char* name, SV *listsv, I32 m
            else SvREFCNT_inc_simple_void_NN(swash_invlist);
        }
 
+        SvREADONLY_on(swash_invlist);
+
         /* Use the inversion list stand-alone if small enough */
         if ((int) _invlist_len(swash_invlist) <= invlist_swash_boundary) {
            SvREFCNT_dec(retval);
@@ -3840,6 +3842,7 @@ Perl__swash_to_invlist(pTHX_ SV* const swash)
        sv_free(other); /* through with it! */
     }
 
+    SvREADONLY_on(invlist);
     return invlist;
 }