CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
793 stars 104 forks source link

Optimise parsing by removing excessive copying. #278

Closed maciejtrybilo closed 5 months ago

maciejtrybilo commented 8 months ago

In the current implementation the copy-on-write causes excessive copying when building the box tree.

I've inlined the merge function into transformToBoxTree and used a storage variable to avoid it being passed around and copied.

In my tests this results in a ~30x speedup and makes all the difference in my use case.

Also IMO the code is a little clearer now as it shows the recursive nature of the algorithm in one function.