After a couple of redesigns the optimisations are almost done now. In almost all cases everything works perfect. It’s now down to good testing before this branch is merged with trunk.
Memory usage for the XML file with a million matches is now only 19% of the original memory usage (from 437Mb down to 85Mb). Scanning a complete file is 10% faster now. But the best is that a small change in the file will no longer cause the complete file to be rescanned: most of the time only a small region needs to be rescanned.