stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.33k stars 221 forks source link

Convert Token from enum to struct #256

Closed ilyapuchka closed 5 years ago

ilyapuchka commented 5 years ago

Resolves #255. Strangely enough, it makes parsing slightly slower, but I still think it's a good thing to do. I didn't want to change too much code so I left static constructors instead of cases for interface to be the same.

djbe commented 5 years ago

Quick question: how did you measure a slowdown?

ilyapuchka commented 5 years ago

in the performance test, it went from 250-something to 260-something

djbe commented 5 years ago

The performance test is always a bit inconsistent though, you have to run it a few times to get an idea if it's a fluke, or an actual increase.

Anyway, 10ms increase isn't a problem in this case.

djbe commented 5 years ago

What we're not noticing now, is a potential performance benefit in other parts of Stencil, as we only measure the lexer performance.

djbe commented 5 years ago

Code looks GTM.

Might be worth adding documentation like I did in https://github.com/stencilproject/Stencil/pull/226/commits/cb4e51484660d17c92c0baa8e4c6f1e1b0f8e1a0, the current codebase can be quite complicated for developers to understand, and the docs should help with that.

Also, don't forget a changelog entry! 😉

ilyapuchka commented 5 years ago

@djbe there is not really much to document except type properties, which are self-explanatory IMO, the Kind ass well but it already had docs.