alecthomas / chroma

A general purpose syntax highlighter in pure Go
MIT License
4.33k stars 395 forks source link

Improve startup time #956

Closed walles closed 4 months ago

walles commented 5 months ago

By not loading styles until they are needed.

This takes moar's startup time down from ~25ms to ~18ms on my machine.

One potential downside of this change is that NewEmbeddedXMLStyle() is added to the public API.

But since styles are split between style.go and styles/api.go I was unable to come up with a solution that didn't change the public API.

Also I'm unsure whether the improved startup performance is worth the extra complexity (which isn't bad really, but still). You be the judge of that.

alecthomas commented 4 months ago

Thanks, but I don't think the extra complexity is worth such a minor gain in performance.