Skip to content

pp_split: reify using NULL rather than PL_sv_undef (gh#18077) #18158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2020

Conversation

richardleach
Copy link
Contributor

Non-existent array elements have been represented by NULL rather than &PL_sv_undef since ce0d59f. As discussed in #18077, an instance of reification in pp_split seems to have not been updated to match.

I'm not sure what ideal Perl code for performance testing is, but trying with @_ suggested that there's little difference between:

        for (i = AvFILLp(ary); i >= 0; i--)
	    AvARRAY(ary)[i] = NULL;

and

        Zero(AvARRAY(ary),AvFILLp(ary) + 1,SV*);

I just went with the latter because it results in a very slightly (16 bytes) smaller pp.o.

make test succeeds locally (64 bit Linux).

Copy link
Contributor

@khwilliamson khwilliamson left a comment

Choose a reason for hiding this comment

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

This LGTM, but I'm not an expert here.

Any reason not to apply this patch?

@atoomic
Copy link
Member

atoomic commented Sep 29, 2020

The Zero solution seems also better IMO than the for loop.
I wonder if we could not use this trick in other locations too shown in ce0d59f

Copy link
Member

@atoomic atoomic left a comment

Choose a reason for hiding this comment

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

Please add a protection for AvFILLp(ary) >= 0

@richardleach
Copy link
Contributor Author

@atoomic -

Please add a protection for AvFILLp(ary) >= 0

As per review comment above, I'm now wondering if the existing loop is redundant and should be removed.

The Zero solution seems also better IMO than the for loop.
I wonder if we could not use this trick in other locations too shown in ce0d59f

I've used Zero() in #18072, which hasn't received any review comments to date.

@richardleach richardleach force-pushed the hydahy/pp_split_gh18077 branch from f9131a6 to a884502 Compare September 29, 2020 22:13
@richardleach
Copy link
Contributor Author

D'oh, I added the originally-requested protection for AvFILLp(ary) >= 0 and force-pushed, and only then noticed the additional review comment stating that it's not necessary. I'll do another push.

@richardleach richardleach force-pushed the hydahy/pp_split_gh18077 branch from a884502 to 9607d52 Compare September 29, 2020 22:21
@richardleach
Copy link
Contributor Author

Additional push done. Functionally that takes this PR back to its original form, but there is now the additional comment about potentially redundant code. (I may well submit a follow-up PR to remove it.)

@khwilliamson khwilliamson merged commit 3777a0a into Perl:blead Oct 8, 2020
@richardleach richardleach deleted the hydahy/pp_split_gh18077 branch October 8, 2020 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants