sipsorcery
sipsorcery copied to clipboard
Change the definition of enum SIPExtensions to allow using as a bitfield
Change the definition of enum SIPExtensions to allow using as a bitfieldeld.
In class SIPHeader, members RequiredExtensions and SupportedExtensions can now become bitfields instead of lists of enums. This results in a smaller memory footprint.
Modify static method ParseSIPExtensions accordingly, and eliminate all string concatenations by using a StringBuilder.
[!IMPORTANT] Although this approch is more idiomatic to C#, and reduces the memory footprint of the library, it is important to note that this modifies the public API, as members SupportedExtensions are RequiredExtensions are public. Please let me know what you think about it.
You are totally right. I kept the same existing logic of the function, but I agree that the string manipulations are not done the best way, and I can go further if needed.
The flag enum is a good improvement. Happy to merge. The change is highly unlikely to affect any library users.
If there are further string optimisations planned it would be better to get them in now.
Thanks for the review. That means that the visibility of the member could be restricted. I'll think about it. I will update the submitted code with the suggestions made by @paulomorgado. Now that I know that we don't want to keep the original mechanics of this function, I'll improve that.