Closed straight-shoota closed 7 years ago
There are also many other Regex.new
that should be cached. One in decode_entities_string
, yet another one in Encoder.encode
. Caching those improves performance again (just caching the first one reduces the time from 0.97s to 0.7s in one benchmark I have). But I don't have time to send a PR for this.
Yes. I've already been working on a few improvements. There is still a lot to do :)
Another one: the HUGE Regex for entities can be simplified to this:
Regex.new("&(?:(\\w+;?)|(#[xX][\\da-fA-F]+;?|#\\d+;?))")
Then you need to check in both legacy and entity mappings. But it's still faster than processing that super big regex.
I also have no much time on crystal. My baby was born recently, only limit time to coding 🤣
@icyleaf Congratulations! Please spend less time with Crystal and more with your baby :-)
Fixup for performance hit introduced by #5 as reported by @asterite
The regexes used by
Decoder.decode
andEncoder.encode
are now cached as constants.