16
16
* [p.278 of _The Lord of the Rings_, II/iii: "The Ring Goes South"]
17
17
*/
18
18
19
- /*
19
+ /*
20
20
=head1 HV Handling
21
21
A HV structure represents a Perl hash. It consists mainly of an array
22
22
of pointers, each of which points to a linked list of HE structures. The
@@ -513,7 +513,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
513
513
((flags & HVhek_UTF8 )
514
514
? SVf_UTF8 : 0 ));
515
515
}
516
-
516
+
517
517
mg -> mg_obj = keysv ; /* pass key */
518
518
uf -> uf_index = action ; /* pass action */
519
519
magic_getuvar (MUTABLE_SV (hv ), mg );
@@ -763,24 +763,25 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
763
763
}
764
764
765
765
if (is_utf8 && !(flags & HVhek_KEYCANONICAL )) {
766
- char * const keysave = (char * )key ;
767
- key = (char * )bytes_from_utf8 ((U8 * )key , & klen , & is_utf8 );
768
- if (is_utf8 )
769
- flags |= HVhek_UTF8 ;
770
- else
771
- flags &= ~HVhek_UTF8 ;
772
- if (key != keysave ) {
773
- if (flags & HVhek_FREEKEY )
774
- Safefree (keysave );
775
- flags |= HVhek_WASUTF8 | HVhek_FREEKEY ;
776
- /* If the caller calculated a hash, it was on the sequence of
777
- octets that are the UTF-8 form. We've now changed the sequence
778
- of octets stored to that of the equivalent byte representation,
779
- so the hash we need is different. */
780
- hash = 0 ;
781
- }
766
+ char * const keysave = (char * )key ;
767
+ key = (char * )bytes_from_utf8 ((U8 * )key , & klen , & is_utf8 );
768
+ if (is_utf8 )
769
+ flags |= HVhek_UTF8 ;
770
+ else
771
+ flags &= ~HVhek_UTF8 ;
772
+ if (key != keysave ) {
773
+ if (flags & HVhek_FREEKEY )
774
+ Safefree (keysave );
775
+ flags |= HVhek_WASUTF8 | HVhek_FREEKEY ;
776
+ /* If the caller calculated a hash, it was on the sequence of
777
+ * octets that are the UTF-8 form. We've now changed the
778
+ * sequence of octets stored to that of the equivalent byte
779
+ * representation, so the hash we need is different. */
780
+ hash = 0 ;
781
+ }
782
782
}
783
783
784
+
784
785
if (keysv && (SvIsCOW_shared_hash (keysv ))) {
785
786
if (HvSHAREKEYS (hv ))
786
787
keysv_hek = SvSHARED_HEK_FROM_PV (SvPVX_const (keysv ));
@@ -912,7 +913,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
912
913
913
914
not_found :
914
915
#ifdef DYNAMIC_ENV_FETCH /* %ENV lookup? If so, try to fetch the value now */
915
- if (!(action & HV_FETCH_ISSTORE )
916
+ if (!(action & HV_FETCH_ISSTORE )
916
917
&& SvRMAGICAL ((const SV * )hv )
917
918
&& mg_find ((const SV * )hv , PERL_MAGIC_env )) {
918
919
unsigned long len ;
@@ -1245,7 +1246,7 @@ Perl_hv_bucket_ratio(pTHX_ HV *hv)
1245
1246
}
1246
1247
else
1247
1248
sv = & PL_sv_zero ;
1248
-
1249
+
1249
1250
return sv ;
1250
1251
}
1251
1252
@@ -1458,7 +1459,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
1458
1459
HvHASKFLAGS_off (hv );
1459
1460
}
1460
1461
1461
- /* If this is a stash and the key ends with ::, then someone is
1462
+ /* If this is a stash and the key ends with ::, then someone is
1462
1463
* deleting a package.
1463
1464
*/
1464
1465
if (sv && SvTYPE (sv ) == SVt_PVGV && HvHasENAME (hv )) {
@@ -2761,7 +2762,7 @@ Perl_hv_ename_add(pTHX_ HV *hv, const char *name, U32 len, U32 flags)
2761
2762
{
2762
2763
assert (* hekp );
2763
2764
if (
2764
- (HEK_UTF8 (* hekp ) || (flags & SVf_UTF8 ))
2765
+ (HEK_UTF8 (* hekp ) || (flags & SVf_UTF8 ))
2765
2766
? hek_eq_pvn_flags (aTHX_ * hekp , name , (I32 )len , flags )
2766
2767
: (HEK_LEN (* hekp ) == (I32 )len && memEQ (HEK_KEY (* hekp ), name , len ))
2767
2768
) {
@@ -2824,7 +2825,7 @@ Perl_hv_ename_delete(pTHX_ HV *hv, const char *name, U32 len, U32 flags)
2824
2825
HEK * * victim = namep + (count < 0 ? - count : count );
2825
2826
while (victim -- > namep + 1 )
2826
2827
if (
2827
- (HEK_UTF8 (* victim ) || (flags & SVf_UTF8 ))
2828
+ (HEK_UTF8 (* victim ) || (flags & SVf_UTF8 ))
2828
2829
? hek_eq_pvn_flags (aTHX_ * victim , name , (I32 )len , flags )
2829
2830
: (HEK_LEN (* victim ) == (I32 )len && memEQ (HEK_KEY (* victim ), name , len ))
2830
2831
) {
@@ -2847,7 +2848,7 @@ Perl_hv_ename_delete(pTHX_ HV *hv, const char *name, U32 len, U32 flags)
2847
2848
return ;
2848
2849
}
2849
2850
if (
2850
- count > 0 && ((HEK_UTF8 (* namep ) || (flags & SVf_UTF8 ))
2851
+ count > 0 && ((HEK_UTF8 (* namep ) || (flags & SVf_UTF8 ))
2851
2852
? hek_eq_pvn_flags (aTHX_ * namep , name , (I32 )len , flags )
2852
2853
: (HEK_LEN (* namep ) == (I32 )len && memEQ (HEK_KEY (* namep ), name , len ))
2853
2854
)
@@ -2856,7 +2857,7 @@ Perl_hv_ename_delete(pTHX_ HV *hv, const char *name, U32 len, U32 flags)
2856
2857
}
2857
2858
}
2858
2859
else if (
2859
- (HEK_UTF8 (aux -> xhv_name_u .xhvnameu_name ) || (flags & SVf_UTF8 ))
2860
+ (HEK_UTF8 (aux -> xhv_name_u .xhvnameu_name ) || (flags & SVf_UTF8 ))
2860
2861
? hek_eq_pvn_flags (aTHX_ aux -> xhv_name_u .xhvnameu_name , name , (I32 )len , flags )
2861
2862
: (HEK_LEN (aux -> xhv_name_u .xhvnameu_name ) == (I32 )len &&
2862
2863
memEQ (HEK_KEY (aux -> xhv_name_u .xhvnameu_name ), name , len ))
@@ -3343,22 +3344,22 @@ Perl_share_hek(pTHX_ const char *str, SSize_t len, U32 hash)
3343
3344
PERL_ARGS_ASSERT_SHARE_HEK ;
3344
3345
3345
3346
if (len < 0 ) {
3346
- STRLEN tmplen = - len ;
3347
- is_utf8 = TRUE;
3348
- /* See the note in hv_fetch(). --jhi */
3349
- str = (char * )bytes_from_utf8 ((U8 * )str , & tmplen , & is_utf8 );
3350
- len = tmplen ;
3351
- /* If we were able to downgrade here, then than means that we were passed
3352
- in a key which only had chars 0-255, but was utf8 encoded. */
3353
- if (is_utf8 )
3354
- flags = HVhek_UTF8 ;
3355
- /* If we found we were able to downgrade the string to bytes, then
3356
- we should flag that it needs upgrading on keys or each. Also flag
3357
- that we need share_hek_flags to free the string. */
3358
- if (str != save ) {
3359
- PERL_HASH (hash , str , len );
3360
- flags |= HVhek_WASUTF8 | HVhek_FREEKEY ;
3361
- }
3347
+ STRLEN tmplen = - len ;
3348
+ is_utf8 = TRUE;
3349
+ /* See the note in hv_fetch(). --jhi */
3350
+ str = (char * )bytes_from_utf8 ((U8 * )str , & tmplen , & is_utf8 );
3351
+ len = tmplen ;
3352
+ /* If we were able to downgrade here, then than means that we were passed
3353
+ in a key which only had chars 0-255, but was utf8 encoded. */
3354
+ if (is_utf8 )
3355
+ flags = HVhek_UTF8 ;
3356
+ /* If we found we were able to downgrade the string to bytes, then
3357
+ we should flag that it needs upgrading on keys or each. Also flag
3358
+ that we need share_hek_flags to free the string. */
3359
+ if (str != save ) {
3360
+ PERL_HASH (hash , str , len );
3361
+ flags |= HVhek_WASUTF8 | HVhek_FREEKEY ;
3362
+ }
3362
3363
}
3363
3364
3364
3365
return share_hek_flags (str , len , hash , flags );
@@ -4008,7 +4009,7 @@ Perl_refcounted_he_free(pTHX_ struct refcounted_he *he) {
4008
4009
HINTS_REFCNT_LOCK ;
4009
4010
new_count = -- he -> refcounted_he_refcnt ;
4010
4011
HINTS_REFCNT_UNLOCK ;
4011
-
4012
+
4012
4013
if (new_count ) {
4013
4014
return ;
4014
4015
}
0 commit comments