Skip to content

Simplify rename pairing and index scoping - #6150

Merged
ilyakuz-db merged 1 commit into
configsync/split-list-write-backfrom
configsync/split-list-write-back-simplify
Aug 3, 2026
Merged

Simplify rename pairing and index scoping#6150
ilyakuz-db merged 1 commit into
configsync/split-list-write-backfrom
configsync/split-list-write-back-simplify

Conversation

@ilyakuz-db

Copy link
Copy Markdown
Contributor

Cleanup pass on top of #6138, kept separate so the changes are reviewable on their own. Behaviour-preserving: no golden files change, all 22 config-remote-sync acceptance directories pass unchanged.

Changes

Resolve the removed element once per rename candidate. sameElementApartFromKey, sameFieldsApartFromKey and multiBlockElement each re-ran resolveSelectors on the same remove path and re-did the same AsAny().(map[string]any) cast and withoutKey strip. They now take the already-stripped oldFields map, resolved once per remove in pairRenames. Drops three near-identical resolve-and-cast preambles and the O(removes x adds) re-resolution — a run renaming N elements went from ~3N tree walks to N.

scopedParent helper for index bookkeeping. scope + resolvedPath.Parent().String() was spelled out at four call sites in ResolveChanges plus adjustArrayIndex. Forgetting that prefix is exactly the cross-block index-shift bug the parent PR fixes, so it is now one named function rather than a string concat to remember.

blocksDefiningSequence: drop the O(n^2) dedup. The loop iterated sortedBlocks() (already distinct by map key) while re-checking !slices.Contains(blocks, block) on every matching location, so a block could never be appended twice anyway. Replaced with a single slices.ContainsFunc over the locations.

Tests

Ran the full config-remote-sync acceptance suite plus the package unit tests; ./task lint-q reports 0 Go issues.

@ilyakuz-db
ilyakuz-db force-pushed the configsync/split-list-write-back-simplify branch from c70f16e to 6f09c49 Compare August 3, 2026 17:21
@ilyakuz-db
ilyakuz-db merged commit 6f09c49 into configsync/split-list-write-back Aug 3, 2026
19 checks passed
@ilyakuz-db
ilyakuz-db deleted the configsync/split-list-write-back-simplify branch August 3, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant