Further improves getDefinedFunctionsInFile()#9249
Merged
Merged
Conversation
Support functions with union types and classes that extend fully qualified types
Comment on lines
+2308
to
+2310
| // Remove multiline comments so regex does not | ||
| // match fake functions/classes inside them. | ||
| $source = preg_replace('~//[^\h]+|/\*.*?\*/~s', '', $source); |
Member
There was a problem hiding this comment.
Suggested change
| // Remove multiline comments so regex does not | |
| // match fake functions/classes inside them. | |
| $source = preg_replace('~//[^\h]+|/\*.*?\*/~s', '', $source); | |
| // Remove multiline comments so regex does not | |
| // match fake functions/classes inside them. | |
| $source = Config::stripPhpComments($source); |
This would produce more thorough and reliable results.
Can I get you to submit a follow-up PR making this change, @live627?
Contributor
Author
There was a problem hiding this comment.
I hadn't noticed that function before now. I'm testing it now. It's quite a bit slower: the one with the token takes 0.43s, while the custom algorithm takes 0.38s. The one in this branch takes 0.08s.
That custom implementation also missed a function.
(new regex = mine, old regex = your suggested change without the tokenizer)
Files: 1599
Iterations: 1
New regex total: 79.910 ms
Old regex total: 378.003 ms
New regex avg: 79.910 ms
Old regex avg: 378.003 ms
Speedup: 4.73x (new regex faster)
New regex count: 4420
Old regex count: 4419
Differences detected:
../../smf2.1/sources\Subs-Compat.php
New regex only:
+ package_crypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support functions with union types and classes that extend fully qualified types
Can now parse nearly the entire SMF codebase as seen in my very long result set https://github.com/live627/benchmark-tests/blob/main/smf/fns.txt
My comparison script https://github.com/live627/benchmark-tests/blob/main/smf/fns.php