Emulate the value of BmFLAGS() using SvTAIL().
authorNicholas Clark <nick@ccl4.org>
Mon, 9 May 2011 11:07:17 +0000 (12:07 +0100)
committerNicholas Clark <nick@ccl4.org>
Sat, 11 Jun 2011 07:40:01 +0000 (09:40 +0200)
Don't set BmFLAGS() in Perl_fbm_compile()

Originally fbm_compile() had an I32 flags argument, which seems to have been
part of case folding/locale improvements. bbce6d69784bf43b removed this.
SvTAIL() was only used in once place until c277df42229d99fe2779dcf1a3ceec16
added the U32 flags argument to fbm_compile(), not used until cf93c79d660ae36c.
That commit also added FBMcf_TAIL and FBMcf_TAIL{z,Z,DOLLAR} but didn't use the
last three. Additionally, it stored the BmFLAGS as part of the compiled table:

+       table[-1] = flags;              /* Not used yet */

f722798beaa43749 added FBMcf_TAIL_DOLLARM, renumbered FBMcf_TAIL{z,Z,DOLLAR},
but still didn't use anything other than FBMcf_TAIL.

The core, nothing on CPAN, and nothing visible to Google codesearch, has ever
used the 4 specialist flags. The only use is 0 or FBMcf_TAIL, which is in
lockstep with SvTAIL() of 0 or non-0.

sv.h
util.c

diff --git a/sv.h b/sv.h
index 3d48316..e4e1f7a 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -1294,13 +1294,10 @@ the scalar's value cannot change unless written to.
 /* SvPOKp not SvPOK in the assertion because the string can be tainted! eg
    perl -T -e '/$^X/'
 */
+
+#define BmFLAGS(sv)            (SvTAIL(sv) ? FBMcf_TAIL : 0)
+
 #if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
-#  define BmFLAGS(sv)                                                  \
-       (*({ SV *const _bmflags = MUTABLE_SV(sv);                       \
-               assert(SvTYPE(_bmflags) == SVt_PVGV);                   \
-               assert(SvVALID(_bmflags));                              \
-           &(((XPVGV*) SvANY(_bmflags))->xnv_u.xbm_s.xbm_flags);       \
-        }))
 #  define BmRARE(sv)                                                   \
        (*({ SV *const _bmrare = MUTABLE_SV(sv);                        \
                assert(SvTYPE(_bmrare) == SVt_PVGV);                    \
@@ -1321,7 +1318,6 @@ the scalar's value cannot change unless written to.
            &(((XPVGV*) SvANY(_bmprevious))->xnv_u.xbm_s.xbm_previous); \
         }))
 #else
-#  define BmFLAGS(sv)          ((XPVGV*) SvANY(sv))->xnv_u.xbm_s.xbm_flags
 #  define BmRARE(sv)           ((XPVGV*) SvANY(sv))->xnv_u.xbm_s.xbm_rare
 #  define BmUSEFUL(sv)         ((XPVGV*) SvANY(sv))->xiv_u.xivu_i32
 #  define BmPREVIOUS(sv)       ((XPVGV*) SvANY(sv))->xnv_u.xbm_s.xbm_previous
diff --git a/util.c b/util.c
index 1c68f3d..24a482f 100644 (file)
--- a/util.c
+++ b/util.c
@@ -601,7 +601,6 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags)
            frequency = PL_freq[s[i]];
        }
     }
-    BmFLAGS(sv) = (U8)flags;
     BmRARE(sv) = s[rarest];
     BmPREVIOUS(sv) = rarest;
     BmUSEFUL(sv) = 100;                        /* Initial value */