X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/f8b5b1ae0ffffe9f2ed056ed98119524101cb8fb..90c09c683be291d22d2f06a3d926b59dc5677958:/sv.c diff --git a/sv.c b/sv.c index ed7047e..826228b 100644 --- a/sv.c +++ b/sv.c @@ -131,6 +131,7 @@ static const char S_destroy[] = "DESTROY"; /* ============================================================================ =head1 Allocation and deallocation of SVs. + An SV (or AV, HV, etc.) is allocated in two parts: the head (struct sv, av, hv...) contains type and reference count information, and for many types, a pointer to the body (struct xrv, xpv, xpviv...), which @@ -769,7 +770,7 @@ Perl_sv_free_arenas(pTHX) /* Here are mid-level routines that manage the allocation of bodies out - of the various arenas. There are 5 kinds of arenas: + of the various arenas. There are 4 kinds of arenas: 1. SV-head arenas, which are discussed and handled above 2. regular body arenas @@ -782,7 +783,7 @@ Perl_sv_free_arenas(pTHX) unused block of them is wasteful. Also, several svtypes dont have bodies; the data fits into the sv-head itself. The arena-root pointer thus has a few unused root-pointers (which may be hijacked - later for arena types 4,5) + later for arena type 4) 3 differs from 2 as an optimization; some body types have several unused fields in the front of the structure (which are kept in-place @@ -791,11 +792,6 @@ Perl_sv_free_arenas(pTHX) are decremented to point at the unused 'ghost' memory, knowing that the pointers are used with offsets to the real memory. - -=head1 SV-Body Allocation - -=cut - Allocation of SV-bodies is similar to SV-heads, differing as follows; the allocation mechanism is used for many body types, so is somewhat more complicated, it uses arena-sets, and has no need for still-live @@ -2872,7 +2868,7 @@ S_uiv_2buf(char *const buf, const IV iv, UV uv, const int is_uv, char **const pe uv = iv; sign = 0; } else { - uv = (iv == IV_MIN) ? (UV)iv : (UV)(-iv); + uv = -(UV)iv; sign = 1; } do { @@ -4335,6 +4331,10 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, SV* sstr, const I32 flags) if (dtype < SVt_PVNV) sv_upgrade(dstr, SVt_PVNV); break; + + case SVt_INVLIST: + invlist_clone(sstr, dstr); + break; default: { const char * const type = sv_reftype(sstr,0); @@ -4352,7 +4352,6 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, SV* sstr, const I32 flags) sv_upgrade(dstr, SVt_REGEXP); break; - case SVt_INVLIST: case SVt_PVLV: case SVt_PVGV: case SVt_PVMG: @@ -5165,9 +5164,8 @@ S_sv_uncow(pTHX_ SV * const sv, const U32 flags) SvCUR_set(sv, cur); *SvEND(sv) = '\0'; } - if (len) { - } else { - unshare_hek(SvSHARED_HEK_FROM_PV(pvx)); + if (! len) { + unshare_hek(SvSHARED_HEK_FROM_PV(pvx)); } #ifdef DEBUGGING if (DEBUG_C_TEST) @@ -12597,7 +12595,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p esignbuf[esignlen++] = plus; } else { - uv = (iv == IV_MIN) ? (UV)iv : (UV)(-iv); + uv = -(UV)iv; esignbuf[esignlen++] = '-'; } }