refactor: extract magic cloning to clone_magic() helper#143
Draft
Koan-Bot wants to merge 1 commit into
Draft
Conversation
The magic cloning logic in sv_clone() was a 107-line inline block that handled ext magic, threads::shared stripping, tie detection, qr vtable nulling, and mg_ptr copying. Extracting it to clone_magic() makes sv_clone() significantly shorter and easier to follow, with zero behavior change. The new function returns the tie-magic count so sv_clone() can still skip direct HV/AV element iteration for tied containers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Extract the 107-line magic cloning block from
sv_clone()into a dedicatedclone_magic()helper function.Why
sv_clone()is ~390 lines with multiple concerns interleaved. The magic cloning section (ext magic dispatch, threads::shared stripping, tie detection, qr vtable nulling, mg_ptr copying) is a self-contained block that can be cleanly separated. This makes sv_clone easier to read and reason about.How
static int clone_magic(SV *ref, SV *clone, HV *hseen, int rdepth, AV *weakrefs)functionTesting
Full test suite passes (28 test files). Build clean with no warnings.
🤖 Generated with Claude Code
Quality Report
Changes: 1 file changed, 121 insertions(+), 108 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline