Skip to content

Conversation

@richardleach
Copy link
Contributor

newSV_type(SVt_PVOBJ) does the following initialization:

  • ObjectMAXFIELD(sv) = -1;
  • ObjectFIELDS(sv) = NULL;

This commit makes two changes to Perl_newSVobject reflecting that:

  1. There's no need for Perl_newSVobject to set either of these fields if fieldcount is zero, so that line is coverted into a DEBUGGING assert()and one added forObjectMAXFIELD(sv)` for completeness.

  2. When fieldcount is non-zero, setting ObjectMAXFIELD(sv) prior to the Newx() is more likely to result in the compiler realising that it only needs to do one ObjectMAXFIELD(sv) STORE rather than two.


  • This set of changes does not require a perldelta entry.

`newSV_type(SVt_PVOBJ)` does the following initialization:
* `ObjectMAXFIELD(sv) = -1;`
* `ObjectFIELDS(sv) = NULL;`

This commit makes two changes to `Perl_newSVobject` reflecting that:

1. There's no need for `Perl_newSVobject` to set either of these fields
if `fieldcount` is zero, so that line is coverted into a DEBUGGING
assert()` and one added for `ObjectMAXFIELD(sv)` for completeness.

2. When `fieldcount` is non-zero, setting `ObjectMAXFIELD(sv)` prior to
the `Newx()` is more likely to result in the compiler realising that
it only needs to do one `ObjectMAXFIELD(sv)` STORE rather than two.
@richardleach richardleach requested a review from leonerd October 10, 2025 19:06
Copy link
Contributor

@leonerd leonerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@richardleach richardleach merged commit 4e66795 into Perl:blead Oct 10, 2025
33 of 34 checks passed
@richardleach richardleach deleted the newSVobject_defaults branch October 10, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants