visibleRange() has a side-effect that the visible range is updated every time the function is called. This is a big problem in createHighlights().
I created a dummy XML file that has an almost 4096 characters long line. I then used the search plugin to replace >< with >\n< to split the line.
Without the patch on my computer it took 1 min 30s to split the lines.
With this patch the time went down to 48s.
The time is still bad, but much better ;)
I wonder if the comment on line 3318 "//ensure that the view is up-to-date, otherwise 'endPos()' might fail!" warns about some corner case that I have not encountered...