Skip to content

Commit 9400eaa

Browse files
committed
Encode the misc SV_* flags using bitshifts rather than decimal integers
1 parent 62a7250 commit 9400eaa

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

sv.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,31 +2046,33 @@ Returns the hash for C<sv> created by C<L</newSVpvn_share>>.
20462046
=cut
20472047
*/
20482048

2049-
#define SV_IMMEDIATE_UNREF 1
2050-
#define SV_GMAGIC 2
2051-
#define SV_COW_DROP_PV 4
2052-
#define SV_NOSTEAL 16
2053-
#define SV_CONST_RETURN 32
2054-
#define SV_MUTABLE_RETURN 64
2055-
#define SV_SMAGIC 128
2056-
#define SV_HAS_TRAILING_NUL 256
2057-
#define SV_COW_SHARED_HASH_KEYS 512
2049+
/* Flags used as `U32 flags` arguments to various functions */
2050+
#define SV_IMMEDIATE_UNREF (1 << 0)
2051+
#define SV_GMAGIC (1 << 1)
2052+
#define SV_COW_DROP_PV (1 << 2)
2053+
/* no (1 << 3) */
2054+
#define SV_NOSTEAL (1 << 4)
2055+
#define SV_CONST_RETURN (1 << 5)
2056+
#define SV_MUTABLE_RETURN (1 << 6)
2057+
#define SV_SMAGIC (1 << 7)
2058+
#define SV_HAS_TRAILING_NUL (1 << 8)
2059+
#define SV_COW_SHARED_HASH_KEYS (1 << 9)
20582060
/* This one is only enabled for PERL_OLD_COPY_ON_WRITE */
20592061
/* XXX This flag actually enabled for any COW. But it appears not to do
20602062
anything. Can we just remove it? Or will it serve some future
20612063
purpose. */
2062-
#define SV_COW_OTHER_PVS 1024
2064+
#define SV_COW_OTHER_PVS (1 << 10)
20632065
/* Make sv_2pv_flags return NULL if something is undefined. */
2064-
#define SV_UNDEF_RETURNS_NULL 2048
2066+
#define SV_UNDEF_RETURNS_NULL (1 << 11)
20652067
/* Tell sv_utf8_upgrade() to not check to see if an upgrade is really needed.
20662068
* This is used when the caller has already determined it is, and avoids
20672069
* redundant work */
2068-
#define SV_FORCE_UTF8_UPGRADE 4096
2070+
#define SV_FORCE_UTF8_UPGRADE (1 << 12)
20692071
/* if (after resolving magic etc), the SV is found to be overloaded,
20702072
* don't call the overload magic, just return as-is */
2071-
#define SV_SKIP_OVERLOAD 8192
2072-
#define SV_CATBYTES 16384
2073-
#define SV_CATUTF8 32768
2073+
#define SV_SKIP_OVERLOAD (1 << 13)
2074+
#define SV_CATBYTES (1 << 14)
2075+
#define SV_CATUTF8 (1 << 15)
20742076

20752077
/* The core is safe for this COW optimisation. XS code on CPAN may not be.
20762078
So only default to doing the COW setup if we're in the core.

0 commit comments

Comments
 (0)