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

Use stringbuilder instead of adding to string #874

Open
1 task
vb2ae opened this issue Oct 8, 2023 · 4 comments
Open
1 task

Use stringbuilder instead of adding to string #874

vb2ae opened this issue Oct 8, 2023 · 4 comments

Comments

@vb2ae
Copy link
Member

vb2ae commented Oct 8, 2023

Change Viewmodelbinder to use a StringBuilder to improve performance

if (MessageBinder.SpecialValues.ContainsKey(specialValue))
                            paramName = specialValue;
                           message += paramName + ",";

Tracking issue for:

@Dennis40816
Copy link
Contributor

Hi, @vb2ae. I've committed a change concerning this issue here. If you find this version satisfactory, I can create a PR.

@Dennis40816
Copy link
Contributor

Additionally, based on BenchmarkDotnet, I conducted a simple assessment on whether to use StringBuilder. I found that for methods with fewer than 3 parameters, the original method seems to have better performance in my environment. You can view the evaluation results on this page. Feel free to take a look if you're interested.

@vb2ae
Copy link
Member Author

vb2ae commented Oct 12, 2023

The code looks good. 'The report you did is awesome. I will have to think about it. I also was thinking since this code runs on a phone we need to worry about memory usage because strings are immutable.

@Dennis40816
Copy link
Contributor

Thank you for your positive feedback. If there are further suggestions down the line, I'd be honored to continue making efforts to address them.

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