Skip to content
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

Improve performance of no-hardcoded-env-urls linter rule #3833

Merged
merged 5 commits into from
Jul 30, 2021

Conversation

anthony-c-martin
Copy link
Member

Closes #3636

@anthony-c-martin anthony-c-martin marked this pull request as ready for review July 30, 2021 15:51
@anthony-c-martin anthony-c-martin enabled auto-merge (squash) July 30, 2021 17:07
"asazure.windows.net",
"region.asazure.windows.net",
"api.loganalytics.iov1",
"api.loganalytics.io",
"asazure.windows.net",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but there were a bunch of duplicates here, and api.loganalytics.iov1 looks like a typo. I've removed them.


public static IEnumerable<(TextSpan RelativeSpan, string Value)> FindHostnameMatches(string hostname, string srcText)
{
bool isExactDomainMatch(int index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isExactDomainMatch

This isn't really checking for any match. It's looking before and after the match to ensure the chars aren't alphanumeric.

Should we rename to something like CheckNoSurroundingAlphaNumericChars or CheckNoLeadingAndNoTrailingAlphaNumericChars?

// check preceeding and trailing chars to verify we're not dealing with a substring
if (isExactDomainMatch(matchIndex))
{
var matchText = srcText.Substring(matchIndex, hostname.Length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substring

I like that this string allocation is deferred until the very end

continue;
}

yield return match;
Copy link
Member

@majastrz majastrz Jul 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yield

Should we add a comment that this rule is on the critical path?

Also, I'm guessing you went with yield to avoid list allocations? Worth commenting on those types of decisions?

Copy link
Member

@majastrz majastrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments, but looks great!

@anthony-c-martin anthony-c-martin merged commit 217fe34 into main Jul 30, 2021
@anthony-c-martin anthony-c-martin deleted the antmarti/perf_experiment branch July 30, 2021 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bicep VSCode extension performance degraded in 0.4.412 on MacOSX
3 participants