-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement toc helper performance #4331
Comments
FYI, due to Hexo rendering process (which I still have little idea about it), the helper will be executed twice. |
Helper execution times are related to the number of rendering times in the template engine, I think if the location of the toc call is reasonable, it will only be executed once. I mentioned this issue because if markown renders can cache the toc, then the toc helper only needs to get the cache instead of parsing the article. However, this will also make hexo more replicated, and the coupling with the plugin increases So I don’t know if it should be done this way |
We might need a For example, if renderer could store ASTs in a global object. Then toc helper could first read it from the object, then decide if the parse is necessary. |
The idea was originally made in #4070, which is now discarded. |
@SukkaW I tested it, the performance did not seem to improve much, but made the code more complicated. Closed. |
Check List
Please check followings before submitting a new feature request.
Feature Request
At present, the way we get toc is to parse the entire article content, this operation is no problem. But if it work with markdown or other renderers together, there will be redundant parsing operations. During the markdown parse, the toc has already been parsed. If we cache them, this will bring better performance
Others
This is an example
master...jiangtj:toc
hexojs/hexo-renderer-marked@master...jiangtj-lab:toc
Result

The text was updated successfully, but these errors were encountered: