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

Revise Regex usage in TrimStackTrace #4266

Open
Youssef1313 opened this issue Dec 7, 2024 · 2 comments
Open

Revise Regex usage in TrimStackTrace #4266

Youssef1313 opened this issue Dec 7, 2024 · 2 comments

Comments

@Youssef1313
Copy link
Member

string[] stackFrames = Regex.Split(stackTrace, Environment.NewLine);

It doesn't make much sense to me to use Regex here.

Not so much allocations but would be good to reduce:

Image

@Youssef1313
Copy link
Member Author

This can even be more efficient than string.Split.

We can do the loop ourselves and use spans to not allocate anything here.

@nohwnd
Copy link
Member

nohwnd commented Dec 9, 2024

Agree. Probably was used because it has overload that takes string, rather than having to wrap the string into array to call string.split.

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

2 participants