Don't copy defunct buffer contents when undoing OOK. #23968
Merged
+34
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously,
Perl_sv_backoffwould always copy the contents of the offsetstring buffer to the start of the buffer when undoing the OOK hack. When
the contents are defunct, this is unnecessary activity.
This PR makes two changes:
Perl_sv_backoffnow only copies whenSvOK(sv)is true.Perl_leave_scopefakes!SvOK(sv)when a lexical SV goes out of scope andsv_backoffis called.Closes GH #23967
Note:The main assumption made here is that
SvOK(sv)is a good proxy for buffer content liveness. It seems reasonable for core, but who knows what people have done in their own XS code.A lesser worry: Perhaps
Perl_leave_scopedoesn't need the SV flags preserving and it'd be okay to toggle theSvOKflags off and keep them off.