Upgrade to Module-Build-0.27_09
[p5sagit/p5-mst-13.2.git] / sv.h
diff --git a/sv.h b/sv.h
index e5fb2d3..d91957c 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -150,6 +150,41 @@ Returns the value of the object's reference count.
 =for apidoc Am|SV*|SvREFCNT_inc|SV* sv
 Increments the reference count of the given SV.
 
+All of the following SvREFCNT_inc* macros are optimized versions of
+SvREFCNT_inc, and can be replaced with SvREFCNT_inc.
+
+=for apidoc Am|SV*|SvREFCNT_inc_NN|SV* sv
+Same as SvREFCNT_inc, but can only be used if you know I<sv>
+is not NULL.  Since we don't have to check the NULLness, it's faster
+and smaller.
+
+=for apidoc Am|SV*|SvREFCNT_inc_void|SV* sv
+Same as SvREFCNT_inc, but can only be used if you don't need the
+return value.  The macro doesn't need to return a meaningful value.
+
+=for apidoc Am|SV*|SvREFCNT_inc_void_NN|SV* sv
+Same as SvREFCNT_inc, but can only be used if you don't need the return
+value, and you know that I<sv> is not NULL.  The macro doesn't need
+to return a meaningful value, or check for NULLness, so it's smaller
+and faster.
+
+=for apidoc Am|SV*|SvREFCNT_inc_simple|SV* sv
+Same as SvREFCNT_inc, but can only be used with simple variables, not
+expressions or pointer dereferences.  Since we don't have to store a
+temporary value, it's faster.
+
+=for apidoc Am|SV*|SvREFCNT_inc_simple_NN|SV* sv
+Same as SvREFCNT_inc_simple, but can only be used if you know I<sv>
+is not NULL.  Since we don't have to check the NULLness, it's faster
+and smaller.
+
+=for apidoc Am|SV*|SvREFCNT_inc_simple_void|SV* sv
+Same as SvREFCNT_inc_simple, but can only be used if you don't need the
+return value.  The macro doesn't need to return a meaningful value.
+
+=for apidoc Am|SV*|SvREFCNT_inc|SV* sv
+Increments the reference count of the given SV.
+
 =for apidoc Am|void|SvREFCNT_dec|SV* sv
 Decrements the reference count of the given SV.
 
@@ -175,11 +210,41 @@ perform the upgrade if necessary.  See C<svtype>.
             (SvREFCNT(_sv))++;         \
        _sv;                            \
     })
+#  define SvREFCNT_inc_simple(sv)      \
+    ({                                 \
+       if (sv)                         \
+            (SvREFCNT(sv))++;          \
+       (SV *)(sv);                             \
+    })
+#  define SvREFCNT_inc_NN(sv)          \
+    ({                                 \
+       SV * const _sv = (SV*)(sv);     \
+       SvREFCNT(_sv)++;                \
+       _sv;                            \
+    })
+#  define SvREFCNT_inc_void(sv)                \
+    ({                                 \
+       SV * const _sv = (SV*)(sv);     \
+       if (_sv)                        \
+           (void)(SvREFCNT(_sv)++);    \
+    })
 #else
 #  define SvREFCNT_inc(sv)     \
-       ((PL_Sv=(SV*)(sv)) ? ((++(SvREFCNT(PL_Sv))),(PL_Sv)) : NULL)
+       ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL)
+#  define SvREFCNT_inc_simple(sv) \
+       ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL)
+#  define SvREFCNT_inc_NN(sv) \
+       (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv)
+#  define SvREFCNT_inc_void(sv) \
+       (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0)
 #endif
 
+/* These guys don't need the curly blocks */
+#define SvREFCNT_inc_simple_void(sv)   if (sv) (SvREFCNT(sv)++);
+#define SvREFCNT_inc_simple_NN(sv)     (++(SvREFCNT(sv)),(SV*)(sv))
+#define SvREFCNT_inc_void_NN(sv)       (void)(++SvREFCNT((SV*)(sv)))
+#define SvREFCNT_inc_simple_void_NN(sv)        (void)(++SvREFCNT((SV*)(sv)))
+
 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC)
 #  define SvREFCNT_dec(sv)             \
     ({                                 \
@@ -330,6 +395,7 @@ struct xpviv {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
 };
 
@@ -344,6 +410,7 @@ typedef struct {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
 } xpviv_allocated;
 #endif
@@ -361,6 +428,7 @@ struct xpvuv {
        IV      xuvu_iv;
        UV      xuvu_uv;        /* unsigned value or pv offset */
        void *  xuvu_p1;
+       HEK *   xivu_namehek;
     }          xuv_u;
 };
 
@@ -378,6 +446,7 @@ struct xpvnv {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
 };
 
@@ -394,6 +463,7 @@ struct xpvmg {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
     union {
        MAGIC*  xmg_magic;      /* linked list of magicalness */
@@ -414,6 +484,7 @@ struct xpvlv {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;   /* GvNAME */
     }          xiv_u;
     union {
        MAGIC*  xmg_magic;      /* linked list of magicalness */
@@ -421,10 +492,6 @@ struct xpvlv {
     } xmg_u;
     HV*                xmg_stash;      /* class package */
 
-    /* a full glob fits into this */
-    char*      xgv_name;
-    STRLEN     xgv_namelen;
-
     STRLEN     xlv_targoff;
     STRLEN     xlv_targlen;
     SV*                xlv_targ;
@@ -440,10 +507,11 @@ struct xpvgv {
     STRLEN     xpv_cur;        /* xgv_flags */
     STRLEN     xpv_len;        /* 0 */
     union {
-       IV      xivu_iv;        /* integer value or pv offset */
+       IV      xivu_iv;
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;   /* GvNAME */
     }          xiv_u;
     union {
        MAGIC*  xmg_magic;      /* linked list of magicalness */
@@ -451,8 +519,6 @@ struct xpvgv {
     } xmg_u;
     HV*                xmg_stash;      /* class package */
 
-    char*      xgv_name;
-    STRLEN     xgv_namelen;
 };
 
 struct xpvbm {
@@ -467,6 +533,7 @@ struct xpvbm {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
     union {
        MAGIC*  xmg_magic;      /* linked list of magicalness */
@@ -495,6 +562,7 @@ struct xpvfm {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
     union {
        MAGIC*  xmg_magic;      /* linked list of magicalness */
@@ -530,6 +598,7 @@ typedef struct {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
     union {
        MAGIC*  xmg_magic;      /* linked list of magicalness */
@@ -569,6 +638,7 @@ struct xpvio {
        UV      xivu_uv;
        void *  xivu_p1;
        I32     xivu_i32;
+       HEK *   xivu_namehek;
     }          xiv_u;
     union {
        MAGIC*  xmg_magic;      /* linked list of magicalness */