Skip to content
  • Vojtech Fried's avatar
    Switching XPath node sorting to Timsort · 3e031b7d
    Vojtech Fried authored and Daniel Veillard's avatar Daniel Veillard committed
    I use libxml xpath engine on quite large (and mostly "flat") xml files.
    It seems that Shellsort, that is used in xmlXPathNodeSetSort is a
    performance bottleneck for my case. I have read some posts about sorting
    in libxml in the libxml archive, but I agree that qsort was not the way
    to go. I experimented with Timsort instead and my results were good for
    me. For about 10000 nodes, my test was about 5x faster with Timsort,
    for 1000 nodes about 10% faster, for small data files, the difference
    was not measurable.
    * timsort.h: the algorithm, kept in a separate header
    * xpath.c: plug in the new algorithm in xmlXPathNodeSetSort
    * Makefile.am: add the header to the EXTRA_DIST
    * doc/apibuild.py: avoid indexing the new header
    3e031b7d