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

avoid allocations by using mirror functions #367

Merged
merged 1 commit into from
Jan 26, 2025

Conversation

alexandear
Copy link
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Problem/Feature

The PR refactors code to use regexp.MatchString to avoid one allocation when converting byte slice to string.

Description of Changes:

  • Replace regexp.Match(s, []byte(input)) with regexp.MatchString(s, input) where input is string.

Checklist

Additional info

This was found with the help of mirror linter, which can be enabled in golangci-lint config.

Copy link
Collaborator

@Ujstor Ujstor left a comment

Choose a reason for hiding this comment

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

LGTM

@Ujstor Ujstor merged commit a034572 into Melkeydev:main Jan 26, 2025
195 checks passed
@alexandear alexandear deleted the refactor-avoid-alloc branch January 26, 2025 21:47
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.

2 participants