refactor(value): migrate Value::Object to Object storage abstraction#736
Open
anakrish wants to merge 1 commit into
Open
refactor(value): migrate Value::Object to Object storage abstraction#736anakrish wants to merge 1 commit into
anakrish wants to merge 1 commit into
Conversation
50770ce to
a7894b2
Compare
Builds on #57. Swap Value::Object's payload from Rc<BTreeMap<Value, Value>> to Rc<Object> and migrate all call sites to the Object API. as_object / as_object_mut keep their names but return &Object / &mut Object. The mutable accessor handles Rc::make_mut internally, so callers no longer do it themselves. Object grows into_value() and From<Object> for Value. Value's serializer now delegates to Object::serialize, dropping a duplicate non-string-key stringification path. RVM IterationState::Object is rewritten around ObjectCursor: O(log n) steps over a shared Rc<Object>, no eager pair snapshot. Snapshot independence is preserved by Rc copy-on-write; setup_next_iteration advances the cursor inline and advance() becomes a no-op for this variant. A new iteration_state_object_is_snapshot_independent_of_source test covers CoW against a mutated alias. Value::Set still wraps Rc<BTreeSet<Value>>; the matching Set abstraction and its swap ship in follow-up PRs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a7894b2 to
21d5431
Compare
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.
Swaps
Value::Object's payload fromRc<BTreeMap<Value, Value>>toRc<Object>and migrates every call site to theObjectAPI.as_object/as_object_mutkeep their names; return types become&Object/&mut Object. The mutable accessor handlesRc::make_mutinternally.Valueserialization delegates toObject::serialize, removing a duplicated non-string-key path.IterationState::Objectis rewritten aroundObjectCursor— O(log n) steps over a sharedRc<Object>, no eager pair snapshot, with CoW for snapshot independence. New testiteration_state_object_is_snapshot_independent_of_sourcecovers the alias-mutation case.entry().or_insertforObject::get_or_insert_with(theentryAPI is intentionally not exposed).Value::Setis unchanged; the matchingSetabstraction and swap ship in the next PRs.This is a semver-major change for
as_object/as_object_mut(return type changes), which will land at the next release.