track currently active features while scanning#318
track currently active features while scanning#318mauke wants to merge 1 commit intoPerl-Critic:masterfrom
Conversation
... instead of repeatedly scanning backwards for all feature enabling/disabling statements every time we need to know the current feature set. In my tests, this massively speeds up parsing of big documents/source files. Fixes Perl-Critic#309.
|
I'll go over this later, but a quick question for now: What happens when the user uses any of these editing methods? https://metacpan.org/pod/PPI::Element#insert_before-@Elements |
|
@wchristian Honestly, I don't know. Presumably the same thing as before? But I can't tell what exactly these methods are supposed to do (or how they are supposed to interact with the tokenizer), anyway. I am reasonably sure that the documentation is wrong:
... because from looking at the code, you can insert multiple elements at once and there are no checks whatsoever. So I guess my answer is:
|
|
Perhaps a better answer: I hadn't thought much about structure-modifying methods like The added state is strictly in PPI::Lexer and PPI::Tokenizer (and the latter is "passive state", fully driven by the actions of PPI::Lexer). The modifications to PPI::Statement::Compound and PPI::Statement::Include by this patch reduce the number of redundant method calls (and in particular, calls to |
|
Thanks @mauke, and first off, sorry for being slow in responding, i'm currently at the other end of completing a 800km apartment move. Everything you said makes sense to me so far, and this particularly just being a speed-up of the initial parse and irrelevant after that's completed makes a lot of sense to me. I'll give it another read-through and release it on wednesday unless i find issues. :) Tho i would like you to answer the question i asked here: https://github.com/Perl-Critic/PPI/pull/318/files/1787646cb412874944cc4e282e546231f5f5a206#diff-f0b7cd24f2b8ce5ab36bffa5ad498650827118f17d0f8369d5633fd5a11944b2R131 because in general i don't mind changes for readability, but prefer feature commit changes to be limited only to making that feature happen. Can you please look at that? |
|
It isn't a change for readability. It eliminates unneeded calls to |
|
Aaaah, thanks. In that case i'll have to add a comment there. :) |
... instead of repeatedly scanning backwards for all feature enabling/disabling statements every time we need to know the current feature set. In my tests, this massively speeds up parsing of big documents/source files.
Fixes #309.
Demonstration:
With PPI 1.284:
With this patch: