Question about swift-markdown detachedFromParent

I just began using swift-markdown and had a question about detachedFromParent.

In my case, I only need to read the Document, I never mutate it. I am largely using child(at:) and child(through:) methods and custom MarkupWalker structs.

For a read-only use case like this, is there any benefit to using detachedFromParent when examining substructures of the document?

Am I correct in thinking that the behavior of child… methods and walker visit… methods will behave identically on an element whether it is still part of a document or detached from it?

(I do see that debugDescription() prints └─ before a non-detached element to indicate that it has a parent. I am guessing that is why the snippet on querying uses detachedFromParent when printing the found element's debug description.)

Are there advantages / disadvantages to detaching from parent? I would imagine for read-only operations such as traversing children or walking subtrees of elements that detaching isn't necessary and not detaching would be more efficient.

I ask because I am new to using the package, so wanted to check if there were additional consideration or nuances I am missing. This seemed to be the forum with the most swift-markdown content so I thought I'd ask here.

Thanks for any guidance on this.

As far as I'm aware there are no advantages to detaching from the parent for read-only operations.

I believe that it's primarily for making changes to the markup or for holding on to a portion of the parsed markup without holding on to the full original data but don't quote me on that one.

Yes, the sub-hierarchies from that node down are identical.

Thank you for replying @ronnqvist and confirming.

I’ve been using swift-markdown for a project for a few weeks now and it has been pretty nice to work with.