samskivert / jmustache

A Java implementation of the Mustache templating language.
Other
828 stars 129 forks source link

Improve escaping performance #166

Closed agentgt closed 7 months ago

agentgt commented 7 months ago

JMustache escaping while surprisingly performant creates unnecessary duplicate objects and is not designed for streams (aka Writer).

This backward compatible enhancement roughly boosts the escaping speed by 40%.

I did JMH benchmarking here in a separate project: https://github.com/jstachio/escape-benchmark

agentgt commented 7 months ago

@samskivert

I have benchmarked on several platforms and it appears the algorithm I picked is in general the fastest option (sparse String[] of char as index). In general its about 2x faster than the existing algorithm.

I have added it to JStachio already.

Let me know if you have any questions.

samskivert commented 7 months ago

Looks peachy, thanks!