diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-04 23:12:01 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-04 23:12:01 +0000 |
commit | 7a4bba223aa750dd886fe6a2fddef224e59c717f (patch) | |
tree | a62d2cfd06d6f0b3dcac09e795b2cb7a34fdb104 /sv.h | |
parent | 7f605079929e971ed43dc83cf99bc51154965c26 (diff) | |
download | perl-7a4bba223aa750dd886fe6a2fddef224e59c717f.tar.gz |
Re-implement the SvOOK() hack to store the offset as a BER encoded
number in the part of the PVX that is being released. (It will always
fit, as chopping off 1 byte gives just enough space for recording a
delta of up to 127). This allows SvOOK() to co-exist with SvIOK_on(),
which means all the calls to SvOOK_off() [with the possibility of a
call to sv_backoff()] in SvIOK_on() can be removed. This ought to make
a lot of straight line code a little bit simpler.
OOK()d scalars can now be SVt_PV, as the IVX isn't needed.
p4raw-id: //depot/perl@32836
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -761,7 +761,7 @@ Set the actual length of the string which is in the SV. See C<SvIV_set>. #define SvOKp(sv) (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) #define SvIOKp(sv) (SvFLAGS(sv) & SVp_IOK) -#define SvIOKp_on(sv) (assert_not_glob(sv) SvRELEASE_IVX(sv), \ +#define SvIOKp_on(sv) (assert_not_glob(sv) SvRELEASE_IVX_(sv) \ SvFLAGS(sv) |= SVp_IOK) #define SvNOKp(sv) (SvFLAGS(sv) & SVp_NOK) #define SvNOKp_on(sv) (assert_not_glob(sv) SvFLAGS(sv) |= SVp_NOK) @@ -770,7 +770,7 @@ Set the actual length of the string which is in the SV. See C<SvIV_set>. SvFLAGS(sv) |= SVp_POK) #define SvIOK(sv) (SvFLAGS(sv) & SVf_IOK) -#define SvIOK_on(sv) (assert_not_glob(sv) SvRELEASE_IVX(sv), \ +#define SvIOK_on(sv) (assert_not_glob(sv) SvRELEASE_IVX_(sv) \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK)) #define SvIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVp_IOK|SVf_IVisUV)) #define SvIOK_only(sv) (SvOK_off(sv), \ @@ -1240,7 +1240,8 @@ the scalar's value cannot change unless written to. if (SvLEN(sv)) { \ assert(!SvROK(sv)); \ if(SvOOK(sv)) { \ - SvPV_set(sv, SvPVX_mutable(sv) - SvIVX(sv)); \ + SvPV_set(sv, SvPVX_mutable(sv) \ + - sv_read_offset(sv)); \ SvFLAGS(sv) &= ~SVf_OOK; \ } \ Safefree(SvPVX(sv)); \ @@ -1714,10 +1715,16 @@ Like C<sv_catsv> but doesn't process magic. #ifdef PERL_OLD_COPY_ON_WRITE #define SvRELEASE_IVX(sv) \ - ((SvIsCOW(sv) ? sv_force_normal_flags(sv, 0) : (void) 0), SvOOK_off(sv)) + ((SvIsCOW(sv) ? sv_force_normal_flags(sv, 0) : (void) 0), 0) # define SvIsCOW_normal(sv) (SvIsCOW(sv) && SvLEN(sv)) +# define SvRELEASE_IVX_(sv) SvRELEASE_IVX(sv), #else -# define SvRELEASE_IVX(sv) SvOOK_off(sv) +# define SvRELEASE_IVX(sv) 0 +/* This little game brought to you by the need to shut this warning up: +mg.c: In function `Perl_magic_get': +mg.c:1024: warning: left-hand operand of comma expression has no effect +*/ +# define SvRELEASE_IVX_(sv) /**/ #endif /* PERL_OLD_COPY_ON_WRITE */ #define CAN_COW_MASK (SVs_OBJECT|SVs_GMG|SVs_SMG|SVs_RMG|SVf_IOK|SVf_NOK| \ |