Skip to content

Commit fd88a92

Browse files
committed
Various functions - when a field is already zero, don't set it to zero.
SV bodies are Zero()ed when allocated/uprooted from an arena for use. This commit changes instances where a fresh body field is unnecessarily assigned a zero/NULL value into an assertion that the field already contains the desired value.
1 parent 3adffae commit fd88a92

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

gv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ S_maybe_add_coresub(pTHX_ HV * const stash, GV *gv,
669669
get hairy. */
670670
cv = MUTABLE_CV(newSV_type(SVt_PVCV));
671671
GvCV_set(gv,cv);
672-
GvCVGEN(gv) = 0;
672+
assert(GvCVGEN(gv) == 0);
673673
CvISXSUB_on(cv);
674674
CvXSUB(cv) = core_xsub;
675675
PoisonPADLIST(cv);

hv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3570,7 +3570,7 @@ S_refcounted_he_value(pTHX_ const struct refcounted_he *he)
35703570
SvPV_set(value, (char *) he->refcounted_he_data + 1);
35713571
SvCUR_set(value, he->refcounted_he_val.refcounted_he_u_len);
35723572
/* This stops anything trying to free it */
3573-
SvLEN_set(value, 0);
3573+
assert(SvLEN(value) == 0);
35743574
SvPOK_on(value);
35753575
SvREADONLY_on(value);
35763576
if ((he->refcounted_he_data[0] & HVrhek_typemask) == HVrhek_PV_UTF8)

op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12320,7 +12320,7 @@ Perl_newSTUB(pTHX_ GV *gv, bool fake)
1232012320
PERL_ARGS_ASSERT_NEWSTUB;
1232112321
assert(!GvCVu(gv));
1232212322
GvCV_set(gv, cv);
12323-
GvCVGEN(gv) = 0;
12323+
assert(GvCVGEN(gv) == 0);
1232412324
if (!fake && GvSTASH(gv) && HvENAME_HEK(GvSTASH(gv)))
1232512325
gv_method_changed(gv);
1232612326
if (SvFAKE(gv)) {

pp_ctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3753,7 +3753,7 @@ S_save_lines(pTHX_ AV *array, SV *sv)
37533753

37543754
sv_setpvn_fresh(tmpstr, s, t - s);
37553755
/* not breakable until we compile a COP for it */
3756-
SvIV_set(tmpstr, 0);
3756+
assert(SvIVX(tmpstr) == 0);
37573757
SvIOK_on(tmpstr);
37583758
av_store(array, line++, tmpstr);
37593759
s = t;

regcomp_invlist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ Perl_new_invlist_C_array_(pTHX_ const UV* const list)
357357
* of the list proper, so start it just after them */
358358
SvPV_set(invlist, (char *) (list + HEADER_LENGTH));
359359

360-
SvLEN_set(invlist, 0); /* Means we own the contents, and the system
361-
shouldn't touch it */
360+
assert(SvLEN(invlist) == 0); /* Means we own the contents, and the system
361+
shouldn't touch it */
362362

363363
*(get_invlist_offset_addr(invlist)) = offset;
364364

0 commit comments

Comments
 (0)