-
Notifications
You must be signed in to change notification settings - Fork 247
Improve line folding and serialization performance #695
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
Conversation
- Update line folding to use StringBuilder and ArrayPool<char> for better performance and memory efficiency. - Ensure compliance with RFC 5545 by handling multi-byte characters correctly. - Add System.Buffers package for netstandard2.0 target framework. Resolves ical-org#693
a59464b to
82ba1c6
Compare
|
|
||
| var result = new StringBuilder(); | ||
| foreach (var v in prop.Values.Where(value => value != null)) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reducing cognitive complexity by splitting up this method
minichma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM. One finding would be that I think it would be desirable for a serializer to treat the values it operates on as immutable but we modify the TZID property of the period list. Not sure we can change that. I know that's not a new pattern though.
|
Excellent, thanks for pointing this out. ical.net/Ical.Net/Serialization/DataTypes/PeriodListSerializer.cs Lines 42 to 46 in 366b705
|
Wonderful! It would be good at some point to get rid of the redundant data we have in this regard now. I.e. we have the |
minichma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just another very small comment
Ical.Net/Utility/TextUtil.cs
Outdated
| const int takeLimit = 74; | ||
| // Use ArrayPool<char> to rent arrays for processing | ||
| // Cannot use Span<char> and stackalloc because netstandard2.0 does not support it | ||
| var arrayPool = ArrayPool<char>.Shared; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the performance optimization the usage of the ArrayPool could bring but I would usually try to avoid using a global pool here. It increases complexity and could have unexpected side effects. Had similar situations (in other languages though) where some memory sanitizer suddenly complained that the globally allocated memory changed after calling a certain method just because of some global cache. This might not be the case here but given the quite small effect we can expect from the optimization (compared to just allocating a new array) and given the fact that we don't know how/where users of the lib will will use it, I would rather avoid it.
Question is, whether its needed at all. Why not directly append to the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KISS, replaced it
|



Resolves #693