This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Remove unused data structure field
authorKarl Williamson <public@khwilliamson.com>
Wed, 13 Feb 2013 22:13:04 +0000 (15:13 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 4 Jul 2013 01:21:17 +0000 (19:21 -0600)
This removes a field that is set in the inversion list data structure
and examined just once.  And that sole examiner is the function that
calls the function that does the set.  In other words X calls Y passing
it data D.  Y puts D into a structure.  Upon return from Y, X looks for
D in the structure.  No one else looks at D.  X might just as well have
looked at D directly, without involving Y, and without the structure
needing a space for D.

embed.fnc
embed.h
proto.h
regcomp.c

index d8a5c63..ff33a38 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1438,7 +1438,6 @@ EiM       |void   |invlist_trim   |NN SV* const invlist
 EiMR   |SV*    |invlist_clone  |NN SV* const invlist
 EiMR   |bool   |invlist_is_iterating|NN SV* const invlist
 EiMR   |UV*    |get_invlist_iter_addr  |NN SV* invlist
-EiMR   |UV*    |get_invlist_version_id_addr    |NN SV* invlist
 EiM    |void   |invlist_iterinit|NN SV* invlist
 EsMR   |bool   |invlist_iternext|NN SV* invlist|NN UV* start|NN UV* end
 EiM    |void   |invlist_iterfinish|NN SV* invlist
diff --git a/embed.h b/embed.h
index 0666e6f..0382be5 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define could_it_be_a_POSIX_class(a)   S_could_it_be_a_POSIX_class(aTHX_ a)
 #define get_invlist_iter_addr(a)       S_get_invlist_iter_addr(aTHX_ a)
 #define get_invlist_previous_index_addr(a)     S_get_invlist_previous_index_addr(aTHX_ a)
-#define get_invlist_version_id_addr(a) S_get_invlist_version_id_addr(aTHX_ a)
 #define get_invlist_zero_addr(a)       S_get_invlist_zero_addr(aTHX_ a)
 #define grok_bslash_N(a,b,c,d,e,f,g)   S_grok_bslash_N(aTHX_ a,b,c,d,e,f,g)
 #define handle_regex_sets(a,b,c,d,e)   S_handle_regex_sets(aTHX_ a,b,c,d,e)
diff --git a/proto.h b/proto.h
index e4e43e1..26f032b 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -6492,12 +6492,6 @@ PERL_STATIC_INLINE IV*   S_get_invlist_previous_index_addr(pTHX_ SV* invlist)
 #define PERL_ARGS_ASSERT_GET_INVLIST_PREVIOUS_INDEX_ADDR       \
        assert(invlist)
 
-PERL_STATIC_INLINE UV* S_get_invlist_version_id_addr(pTHX_ SV* invlist)
-                       __attribute__warn_unused_result__
-                       __attribute__nonnull__(pTHX_1);
-#define PERL_ARGS_ASSERT_GET_INVLIST_VERSION_ID_ADDR   \
-       assert(invlist)
-
 PERL_STATIC_INLINE UV* S_get_invlist_zero_addr(pTHX_ SV* invlist)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
index 0ee7bc5..fb54b83 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7225,7 +7225,6 @@ Perl__new_invlist(pTHX_ IV initial_size)
     *(zero_addr + 1) = 0;
 
     *get_invlist_previous_index_addr(new_list) = 0;
-    *get_invlist_version_id_addr(new_list) = INVLIST_VERSION_ID;
 #if HEADER_LENGTH != 6
 #   error Need to regenerate INVLIST_VERSION_ID by running perl -E 'say int(rand 2**31-1)', and then changing the #if to the new length
 #endif
@@ -7251,7 +7250,7 @@ S__new_invlist_C_array(pTHX_ UV* list)
                               shouldn't touch it */
     SvCUR_set(invlist, TO_INTERNAL_SIZE(_invlist_len(invlist)));
 
-    if (*get_invlist_version_id_addr(invlist) != INVLIST_VERSION_ID) {
+    if (list[INVLIST_VERSION_ID_OFFSET] != INVLIST_VERSION_ID) {
         Perl_croak(aTHX_ "panic: Incorrect version for previously generated inversion list");
     }
     invlist_set_len(invlist, list[INVLIST_LEN_OFFSET]);
@@ -8143,16 +8142,6 @@ S_get_invlist_iter_addr(pTHX_ SV* invlist)
     return (UV *) (SvPVX(invlist) + (INVLIST_ITER_OFFSET * sizeof (UV)));
 }
 
-PERL_STATIC_INLINE UV*
-S_get_invlist_version_id_addr(pTHX_ SV* invlist)
-{
-    /* Return the address of the UV that contains the version id. */
-
-    PERL_ARGS_ASSERT_GET_INVLIST_VERSION_ID_ADDR;
-
-    return (UV *) (SvPVX(invlist) + (INVLIST_VERSION_ID_OFFSET * sizeof (UV)));
-}
-
 PERL_STATIC_INLINE void
 S_invlist_iterinit(pTHX_ SV* invlist)  /* Initialize iterator for invlist */
 {