Caliburn-Micro / Caliburn.Micro

A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
http://caliburnmicro.com/
MIT License
2.79k stars 775 forks source link

Use stringbuilder instead of adding to string #874

Open vb2ae opened 10 months ago

vb2ae commented 10 months ago

Change Viewmodelbinder to use a StringBuilder to improve performance

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

Tracking issue for:

Dennis40816 commented 10 months ago

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

Dennis40816 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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.