Improve TokenUtils performance through caching

For #9717.

For testing, you can take https://gist.github.com/MarcelGerber/5c11f1031af292044708, placing your cursor in the script tags and pressing `Ctrl-Space`.
I only brought up `TokenUtils.getModeAt()` because I thought that it may benefit from the cache, but that does not appear to be the case. To keep these improvements isolated so they can be measured separately, this change should be moved to another pull request.