Add Node.existingOrNewChildNode — recycles an existing node. Creates a new node only when needed.
This commit is contained in:
parent
b19d15ed3f
commit
0221eda956
|
@ -81,6 +81,14 @@ public final class Node: Hashable {
|
|||
return node
|
||||
}
|
||||
|
||||
public func existingOrNewChildNode(with representedObject: AnyObject) -> Node {
|
||||
|
||||
if let node = childNodeRepresentingObject(representedObject) {
|
||||
return node
|
||||
}
|
||||
return createChildNode(representedObject)
|
||||
}
|
||||
|
||||
public func createChildNode(_ representedObject: AnyObject) -> Node {
|
||||
|
||||
// Just creates — doesn’t add it.
|
||||
|
|
Loading…
Reference in New Issue