Skip to content
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

S_fold_constants: remove early SvREADONLY(sv) to allow SvIsCOW(sv) #20595

Merged
merged 1 commit into from
Jun 11, 2024

Commits on Jun 10, 2024

  1. S_fold_constants: remove early SvREADONLY(sv) to allow SvIsCOW(sv)

    Standard CONST PVs have the IsCOW flag set, meaning that COW can
    be used when assigning the CONST to a variable, rather than making
    a copy of the buffer. CONST PVs arising from constant folding have
    been lacking this flag, leading to unnecessary copying of PV buffers.
    
    This seems to have occurred because a common branch in S_fold_constants
    marks SVs as READONLY before the new CONST OP is created. When the OP
    is created, the Perl_ck_svconst() check function is called - this is
    the same as when a standard CONST OP is created. If the SV is not
    already marked as READONLY, the check function will try to set IsCOW
    if it is safe to do so, then in either case will make sure that the
    READONLY flag is set.
    
    This commit therefore removes the SvREADONLY(sv) statement from
    S_fold_constants(), allowing Perl_ck_svconst() to set the IsCOW
    and READONLY flags itself. Minor test updates are also included.
    richardleach committed Jun 10, 2024
    Configuration menu
    Copy the full SHA
    c1c8af3 View commit details
    Browse the repository at this point in the history