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

Analyser to warn against wasteful string.Split calls #161

Open
yaakov-h opened this issue Nov 1, 2021 · 1 comment
Open

Analyser to warn against wasteful string.Split calls #161

yaakov-h opened this issue Nov 1, 2021 · 1 comment
Assignees

Comments

@yaakov-h
Copy link
Member

yaakov-h commented Nov 1, 2021

i.e.:

"abc def ghi jkl".Split(' ')[0]

No point allocating substrings (plus the containing array) that all get immediately discarded.

@yaakov-h yaakov-h self-assigned this Nov 1, 2021
@yaakov-h
Copy link
Member Author

yaakov-h commented Nov 1, 2021

This one might need some flow analysis:

var bits = key.Split('|');
return bits[0];

Unless we just want to ban string.Split entirely, but that idea doesn't sit well with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant