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

Compile regexp's at build time. Use raw string literals for patterns … #167

Merged

Conversation

mrngm
Copy link
Contributor

@mrngm mrngm commented Oct 29, 2019

…to avoid escaping

This avoids patterns like "\\.id_rsa.*$", where the \ needs to be escaped such that Go's string interpreter correctly feeds \.id_rsa.*$ to regexp.MustCompile (or regexp.Compile).

This improves legibility.

Note that in RE2, \n is still interpreted as a newline by regexp, whereas prior to this PR, Go's string interpreter would have converted it to the newline character.

There is also a minor optimization in func NewIgnores, that reuses the group variable inside the loop, by definining it outside of the for.

In theory, these changes will impact #152 positively.

@svishwanath-tw svishwanath-tw merged commit 601a9bd into thoughtworks:master Oct 31, 2019
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.

None yet

2 participants