diff options
author | Perl 5 Porters <perl5-porters@africa.nicoh.com> | 1996-06-19 20:12:08 +0000 |
---|---|---|
committer | Charles Bailey <bailey@genetics.upenn.edu> | 1996-06-19 20:12:08 +0000 |
commit | bf6bd8876f5c82478753ddc8ce036db60ddde40e (patch) | |
tree | 0c2479a22faf0c13e641f73b56a0fa1b336a6004 /hv.h | |
parent | fde52b5cc5a5093c19adc4c8444d3cef2f199541 (diff) | |
download | perl-bf6bd8876f5c82478753ddc8ce036db60ddde40e.tar.gz |
Add shared hash key support
Diffstat (limited to 'hv.h')
-rw-r--r-- | hv.h | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -32,6 +32,23 @@ struct xpvhv { char *xhv_name; /* name, if a symbol table */ }; +#define PERL_HASH(hash,str,len) \ + STMT_START { \ + register char *s_PeRlHaSh = str; \ + register I32 i_PeRlHaSh = len; \ + register U32 hash_PeRlHaSh = 0; \ + while (i_PeRlHaSh--) \ + hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ + (hash) = hash_PeRlHaSh; \ + } STMT_END + + +/* these hash entry flags ride on hent_klen */ + +#define HEf_LAZYDEL -1 /* entry must be deleted during next iter step */ +#define HEf_SVKEY -2 /* hent_key is a SV* (only for magic/tied HVs) */ + + #define Nullhv Null(HV*) #define HvARRAY(hv) ((HE**)((XPVHV*) SvANY(hv))->xhv_array) #define HvFILL(hv) ((XPVHV*) SvANY(hv))->xhv_fill @@ -42,6 +59,10 @@ struct xpvhv { #define HvPMROOT(hv) ((XPVHV*) SvANY(hv))->xhv_pmroot #define HvNAME(hv) ((XPVHV*) SvANY(hv))->xhv_name +#define HvSHAREKEYS(hv) (SvFLAGS(hv) & SVphv_SHAREKEYS) +#define HvSHAREKEYS_on(hv) (SvFLAGS(hv) |= SVphv_SHAREKEYS) +#define HvSHAREKEYS_off(hv) (SvFLAGS(hv) &= ~SVphv_SHAREKEYS) + #ifdef OVERLOAD /* Maybe amagical: */ @@ -58,3 +79,23 @@ struct xpvhv { */ #endif /* OVERLOAD */ + +#define Nullhe Null(HE*) +#define HeNEXT(he) (he)->hent_next +#define HeKEY(he) (he)->hent_key +#define HeKLEN(he) (he)->hent_klen +#define HeVAL(he) (he)->hent_val +#define HeHASH(he) (he)->hent_hash +#define HePV(he) ((he)->hent_klen == HEf_SVKEY) ? \ + SvPV((SV*)((he)->hent_key),na) : \ + (he)->hent_key)) +#define HeSVKEY(he) (((he)->hent_key && \ + (he)->hent_klen == HEf_SVKEY) ? \ + (SV*)((he)->hent_key) : Nullsv) + +#define HeSVKEY_force(he) ((he)->hent_key ? \ + (((he)->hent_klen == HEf_SVKEY) ? \ + (SV*)((he)->hent_key) : \ + sv_2mortal(newSVpv((he)->hent_key, \ + (he)->hent_klen))) : \ + &sv_undef) |