Skip to content

Commit d947902

Browse files
committed
Refactor: standardize copy/postCopy lifecycle
1 parent 2fbbb85 commit d947902

1 file changed

Lines changed: 4 additions & 24 deletions

File tree

src/Containers-KeyedTree/CTKeyedTree.class.st

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -268,21 +268,6 @@ CTKeyedTree >> collect: aBlock [
268268
^ result
269269
]
270270

271-
{ #category : 'copying' }
272-
CTKeyedTree >> copy [
273-
274-
"Answer a deep copy of the receiver including all subtrees."
275-
276-
| result |
277-
result := self species new.
278-
self keysAndValuesDo: [ :key :value |
279-
result at: key put: (
280-
(value isKindOf: self class)
281-
ifTrue: [ value copy ]
282-
ifFalse: [ value ] ) ].
283-
^ result
284-
]
285-
286271
{ #category : 'accessing' }
287272
CTKeyedTree >> depth [
288273

@@ -496,16 +481,11 @@ CTKeyedTree >> pathsAndValuesDo: aBlock currentPath: pathArray [
496481

497482
{ #category : 'copying' }
498483
CTKeyedTree >> postCopy [
499-
500-
"Ensure proper deep copying of associations and subtrees."
501484

502-
array := array collect: [ :assoc |
503-
assoc ifNotNil: [
504-
Association
505-
key: assoc key
506-
value: ((assoc value isKindOf: self class)
507-
ifTrue: [ assoc value copy ]
508-
ifFalse: [ assoc value ]) ] ]
485+
super postCopy.
486+
self keysAndValuesDo: [ :key :value |
487+
(value isKindOf: self class)
488+
ifTrue: [ self at: key put: value copy ] ]
509489
]
510490

511491
{ #category : 'printing' }

0 commit comments

Comments
 (0)