-
Notifications
You must be signed in to change notification settings - Fork 344
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
Move a specific regex to static variable #346
Move a specific regex to static variable #346
Conversation
imo the principle is what's important - as @spencerschrock said on #333 right now it happens that scorecard is scanning a large amount of yarn lockfiles relative to other lockfiles, so that's why this seems the slowest but that could very easily change and I know there's a huge regexp for So while I agree it's not necessarily worth the extra complexity of |
@G-Rath Good point, I added a utility function that'll cache regex's globally and replaced most instances of regexp.MustCompile with it, so it should be relatively painless to use in the future as well. PTAL |
I like the cached regex package approach, provides a simple replacement call without sacrificing readability or usability conventions that a caller would be responsible for following. Wasn't aware of
|
fwiw it looks like this package provides exactly what you want, and doesn't have any other dependencies |
It does look like basically what is implemented here, but since this is just a couple of lines, I don't think it's necessary to pull in a dependency. |
+1. It's pretty trivial, and not worth adding this to our supply chain. |
google/osv-scanner#346 Signed-off-by: Spencer Schrock <sschrock@google.com>
https: //github.com/google/osv-scanner/pull/346 Signed-off-by: Spencer Schrock <sschrock@google.com>
google/osv-scanner#346 Signed-off-by: Spencer Schrock <sschrock@google.com>
) * Recover from osv-scanner panics. This allows us to give an inconclusive score instead of crashing. Signed-off-by: Spencer Schrock <sschrock@google.com> * Bump osv-scanner to include performance increase. google/osv-scanner#346 Signed-off-by: Spencer Schrock <sschrock@google.com> --------- Signed-off-by: Spencer Schrock <sschrock@google.com>
…sf#2896) * Recover from osv-scanner panics. This allows us to give an inconclusive score instead of crashing. Signed-off-by: Spencer Schrock <sschrock@google.com> * Bump osv-scanner to include performance increase. google/osv-scanner#346 Signed-off-by: Spencer Schrock <sschrock@google.com> --------- Signed-off-by: Spencer Schrock <sschrock@google.com> Signed-off-by: Avishay <avishay.balter@gmail.com>
Fixes #333
I measured the time taken to compile the regexp at startup and it's unnoticeable for these regexp, so I don't think we need the added complexity with
sync.Once
.