Skip to content

Avoid unnecessary map allocation in parseExcludeInterfaces #257

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chengpeng-wang
Copy link

Hi, I found that when *excludeInterfaces at line 79 in the file mockgen/parse.go is in the form of ",,,," and " , , ", the function parseExcludeInterfaces will create unnecessary map allocation or maintain whitespace entries as the names of excluded interfaces [Link], which is not necessary.

With this patch, the function parseExcludeInterfaces now returns nil instead, which more accurately represents the absence of exclusions and avoids a redundant allocation.

This change is fully backward-compatible and requires no changes in downstream code. I think this patch can improve the code quality due to the better input validation and format check. Please let me know whether you need more adjustment on the patch.

@chengpeng-wang chengpeng-wang changed the title Avoid unnecessary map allocation in parseExcludeInterfaces for empty … Avoid unnecessary map allocation in parseExcludeInterfaces Jun 4, 2025
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.

1 participant